Refactor for update entities, remove 'documents' validation
This commit is contained in:
parent
0d96e989f5
commit
cf023a100e
|
|
@ -48,8 +48,6 @@ class UpdateClientRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000';
|
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000';
|
||||||
$rules['industry_id'] = 'integer|nullable';
|
$rules['industry_id'] = 'integer|nullable';
|
||||||
|
|
@ -103,15 +101,14 @@ class UpdateClientRequest extends Request
|
||||||
/** @var \App\Models\User $user */
|
/** @var \App\Models\User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($input['settings']['currency_id'])) {
|
if (empty($input['settings']['currency_id'])) {
|
||||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,13 @@ class StoreCreditRequest extends Request
|
||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
$this->files->set('documents', [$this->file('documents')]);
|
||||||
}
|
}
|
||||||
|
|
@ -101,36 +106,6 @@ class StoreCreditRequest extends Request
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('is_amount_discount', $input) && is_bool($input['is_amount_discount'])) {
|
|
||||||
$input['is_amount_discount'] = $this->setBoolean($input['is_amount_discount']);
|
|
||||||
} else {
|
|
||||||
$input['is_amount_discount'] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['exchange_rate'])) {
|
|
||||||
$input['exchange_rate'] = $this->parseFloat($input['exchange_rate']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['amount'])) {
|
|
||||||
$input['amount'] = $this->parseFloat($input['amount']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['custom_surcharge1'])) {
|
|
||||||
$input['custom_surcharge1'] = $this->parseFloat($input['custom_surcharge1']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['custom_surcharge2'])) {
|
|
||||||
$input['custom_surcharge2'] = $this->parseFloat($input['custom_surcharge2']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['custom_surcharge3'])) {
|
|
||||||
$input['custom_surcharge3'] = $this->parseFloat($input['custom_surcharge3']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($input['custom_surcharge4'])) {
|
|
||||||
$input['custom_surcharge4'] = $this->parseFloat($input['custom_surcharge4']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +114,23 @@ class StoreCreditRequest extends Request
|
||||||
$input['partial_due_date'] = null;
|
$input['partial_due_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
if (!isset($input['tax_rate1'])) {
|
||||||
|
$input['tax_rate1'] = 0;
|
||||||
|
}
|
||||||
|
if (!isset($input['tax_rate2'])) {
|
||||||
|
$input['tax_rate2'] = 0;
|
||||||
|
}
|
||||||
|
if (!isset($input['tax_rate3'])) {
|
||||||
|
$input['tax_rate3'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('exchange_rate', $input) && is_null($input['exchange_rate'])) {
|
||||||
|
$input['exchange_rate'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($input['date'])) {
|
||||||
|
$input['date'] = now()->addSeconds($user->company()->utc_offset())->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,8 @@ class UpdateCreditRequest extends Request
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
|
|
||||||
$rules['file.*'] = $this->fileValidation();
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
|
|
||||||
|
|
||||||
$rules['number'] = ['bail', 'sometimes', 'nullable', Rule::unique('credits')->where('company_id', $user->company()->id)->ignore($this->credit->id)];
|
$rules['number'] = ['bail', 'sometimes', 'nullable', Rule::unique('credits')->where('company_id', $user->company()->id)->ignore($this->credit->id)];
|
||||||
|
|
||||||
|
|
@ -94,8 +90,8 @@ class UpdateCreditRequest extends Request
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
if (isset($input['documents'])) {
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@ class StoreExpenseRequest extends Request
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
$rules['documents'] = 'bail|sometimes|array';
|
||||||
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
||||||
|
|
||||||
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
|
$rules['file.*'] = $this->fileValidation();
|
||||||
|
$rules['documents'] = 'bail|sometimes|array';
|
||||||
|
$rules['documents.*'] = $this->fileValidation();
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,6 +73,14 @@ class StoreExpenseRequest extends Request
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
|
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
$this->files->set('documents', [$this->file('documents')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
$this->files->set('file', [$this->file('file')]);
|
||||||
|
}
|
||||||
|
|
||||||
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
||||||
$input['currency_id'] = (string) $user->company()->settings->currency_id;
|
$input['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ class UpdateExpenseRequest extends Request
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
$rules['documents'] = 'bail|sometimes|array';
|
||||||
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
||||||
|
|
||||||
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
|
$rules['file.*'] = $this->fileValidation();
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +74,11 @@ class UpdateExpenseRequest extends Request
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
$this->files->set('file', [$this->file('file')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,11 @@ class StoreInvoiceRequest extends Request
|
||||||
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($input['partial']) && $input['partial'] == 0) {
|
if (isset($input['partial']) && $input['partial'] == 0) {
|
||||||
$input['partial_due_date'] = null;
|
$input['partial_due_date'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($input['tax_rate1'])) {
|
if (!isset($input['tax_rate1'])) {
|
||||||
$input['tax_rate1'] = 0;
|
$input['tax_rate1'] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ class UpdateInvoiceRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
$rules['number'] = ['bail', 'sometimes', 'nullable', Rule::unique('invoices')->where('company_id', $user->company()->id)->ignore($this->invoice->id)];
|
$rules['number'] = ['bail', 'sometimes', 'nullable', Rule::unique('invoices')->where('company_id', $user->company()->id)->ignore($this->invoice->id)];
|
||||||
|
|
||||||
|
|
@ -99,10 +97,6 @@ class UpdateInvoiceRequest extends Request
|
||||||
|
|
||||||
$input['id'] = $this->invoice->id;
|
$input['id'] = $this->invoice->id;
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +110,7 @@ class UpdateInvoiceRequest extends Request
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if (isset($input['documents'])) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ class UpdatePaymentRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
@ -66,10 +64,6 @@ class UpdatePaymentRequest extends Request
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +72,10 @@ class UpdatePaymentRequest extends Request
|
||||||
unset($input['amount']);
|
unset($input['amount']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
||||||
foreach ($input['invoices'] as $key => $value) {
|
foreach ($input['invoices'] as $key => $value) {
|
||||||
if (isset($input['invoices'][$key]['invoice_id'])) {
|
if (isset($input['invoices'][$key]['invoice_id'])) {
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ class UpdateProductRequest extends Request
|
||||||
$rules = [];
|
$rules = [];
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
$rules['cost'] = 'numeric';
|
$rules['cost'] = 'numeric';
|
||||||
$rules['price'] = 'numeric';
|
$rules['price'] = 'numeric';
|
||||||
|
|
@ -55,10 +53,6 @@ class UpdateProductRequest extends Request
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +61,10 @@ class UpdateProductRequest extends Request
|
||||||
$input['quantity'] = 1;
|
$input['quantity'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
|
if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) {
|
||||||
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ class UpdateProjectRequest extends Request
|
||||||
$rules['task_rate'] = 'sometimes|bail|numeric';
|
$rules['task_rate'] = 'sometimes|bail|numeric';
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
@ -60,9 +58,6 @@ class UpdateProjectRequest extends Request
|
||||||
{
|
{
|
||||||
$input = $this->decodePrimaryKeys($this->all());
|
$input = $this->decodePrimaryKeys($this->all());
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
|
|
@ -80,6 +75,10 @@ class UpdateProjectRequest extends Request
|
||||||
$input['budgeted_hours'] = 0;
|
$input['budgeted_hours'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,7 @@ class UpdatePurchaseOrderRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
$rules['status_id'] = 'sometimes|integer|in:1,2,3,4,5';
|
$rules['status_id'] = 'sometimes|integer|in:1,2,3,4,5';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999'];
|
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999'];
|
||||||
|
|
@ -86,8 +85,8 @@ class UpdatePurchaseOrderRequest extends Request
|
||||||
|
|
||||||
$input['id'] = $this->purchase_order->id;
|
$input['id'] = $this->purchase_order->id;
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
if (isset($input['documents'])) {
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@ class UpdateQuoteRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
$rules['invitations'] = 'sometimes|bail|array';
|
$rules['invitations'] = 'sometimes|bail|array';
|
||||||
$rules['invitations.*.client_contact_id'] = 'bail|required|distinct';
|
$rules['invitations.*.client_contact_id'] = 'bail|required|distinct';
|
||||||
|
|
@ -82,10 +80,6 @@ class UpdateQuoteRequest extends Request
|
||||||
|
|
||||||
$input['id'] = $this->quote->id;
|
$input['id'] = $this->quote->id;
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +89,7 @@ class UpdateQuoteRequest extends Request
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if (isset($input['documents'])) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,7 @@ class UpdateRecurringExpenseRequest extends Request
|
||||||
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
@ -75,8 +74,8 @@ class UpdateRecurringExpenseRequest extends Request
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
if (isset($input['documents'])) {
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
|
@ -87,10 +86,6 @@ class UpdateRecurringExpenseRequest extends Request
|
||||||
$input['next_send_date_client'] = $input['next_send_date'];
|
$input['next_send_date_client'] = $input['next_send_date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
|
||||||
unset($input['documents']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
if (! array_key_exists('currency_id', $input) || strlen($input['currency_id']) == 0) {
|
||||||
$input['currency_id'] = (string) $user->company()->settings->currency_id;
|
$input['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,6 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
$rules['number'] = ['bail', 'sometimes', Rule::unique('recurring_invoices')->where('company_id', $user->company()->id)->ignore($this->recurring_invoice->id)];
|
$rules['number'] = ['bail', 'sometimes', Rule::unique('recurring_invoices')->where('company_id', $user->company()->id)->ignore($this->recurring_invoice->id)];
|
||||||
|
|
||||||
|
|
@ -81,9 +79,6 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
|
|
@ -146,7 +141,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||||
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if (isset($input['documents'])) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,7 @@ class UpdateRecurringQuoteRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
if ($this->number) {
|
if ($this->number) {
|
||||||
$rules['number'] = Rule::unique('recurring_quotes')->where('company_id', auth()->user()->company()->id)->ignore($this->recurring_quote->id);
|
$rules['number'] = Rule::unique('recurring_quotes')->where('company_id', auth()->user()->company()->id)->ignore($this->recurring_quote->id);
|
||||||
|
|
@ -55,10 +54,6 @@ class UpdateRecurringQuoteRequest extends Request
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +66,7 @@ class UpdateRecurringQuoteRequest extends Request
|
||||||
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('documents', $input)) {
|
if (isset($input['documents'])) {
|
||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,7 @@ class UpdateTaskRequest extends Request
|
||||||
|
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
@ -97,10 +96,6 @@ class UpdateTaskRequest extends Request
|
||||||
{
|
{
|
||||||
$input = $this->decodePrimaryKeys($this->all());
|
$input = $this->decodePrimaryKeys($this->all());
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -109,6 +104,10 @@ class UpdateTaskRequest extends Request
|
||||||
$input['status_id'] = $this->decodePrimaryKey($input['status_id']);
|
$input['status_id'] = $this->decodePrimaryKey($input['status_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure the project is related */
|
/* Ensure the project is related */
|
||||||
if (array_key_exists('project_id', $input) && isset($input['project_id'])) {
|
if (array_key_exists('project_id', $input) && isset($input['project_id'])) {
|
||||||
$project = Project::withTrashed()->where('id', $input['project_id'])->company()->first();
|
$project = Project::withTrashed()->where('id', $input['project_id'])->company()->first();
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,7 @@ class UpdateVendorRequest extends Request
|
||||||
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
|
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
|
||||||
$rules['file'] = 'bail|sometimes|array';
|
$rules['file'] = 'bail|sometimes|array';
|
||||||
$rules['file.*'] = $this->fileValidation();
|
$rules['file.*'] = $this->fileValidation();
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
|
||||||
$rules['documents.*'] = $this->fileValidation();
|
|
||||||
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';
|
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';
|
||||||
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
$rules['classification'] = 'bail|sometimes|nullable|in:individual,business,company,partnership,trust,charity,government,other';
|
||||||
|
|
||||||
|
|
@ -84,10 +83,6 @@ class UpdateVendorRequest extends Request
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if ($this->file('documents') instanceof \Illuminate\Http\UploadedFile) {
|
|
||||||
$this->files->set('documents', [$this->file('documents')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
if ($this->file('file') instanceof \Illuminate\Http\UploadedFile) {
|
||||||
$this->files->set('file', [$this->file('file')]);
|
$this->files->set('file', [$this->file('file')]);
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +91,10 @@ class UpdateVendorRequest extends Request
|
||||||
$input['name'] = strip_tags($input['name']);
|
$input['name'] = strip_tags($input['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($input['documents'])) {
|
||||||
|
unset($input['documents']);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('country_id', $input) && is_null($input['country_id'])) {
|
if (array_key_exists('country_id', $input) && is_null($input['country_id'])) {
|
||||||
unset($input['country_id']);
|
unset($input['country_id']);
|
||||||
} elseif (!$this->vendor->country_id) {
|
} elseif (!$this->vendor->country_id) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue