diff --git a/app/Http/Requests/Credit/UpdateCreditRequest.php b/app/Http/Requests/Credit/UpdateCreditRequest.php index 265b1ef71558..97a951df955b 100644 --- a/app/Http/Requests/Credit/UpdateCreditRequest.php +++ b/app/Http/Requests/Credit/UpdateCreditRequest.php @@ -43,7 +43,7 @@ class UpdateCreditRequest extends FormRequest } if($this->input('number')) - $rules['number'] = 'unique:quotes,number,' . $this->id . ',id,company_id,' . $this->credit->company_id; + $rules['number'] = 'unique:credits,number,' . $this->id . ',id,company_id,' . $this->credit->company_id; return $rules; } @@ -83,6 +83,8 @@ class UpdateCreditRequest extends FormRequest $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + $input['id'] = $this->credit->id; + $this->replace($input); } } diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index d48b84130834..2907fc2e13bf 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -75,7 +75,10 @@ class UpdateInvoiceRequest extends Request if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) { $input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']); } - + info($input['due_date']); + //unset($input['due_date']); + //unset($input['date']); + if (isset($input['invitations'])) { foreach ($input['invitations'] as $key => $value) { if (array_key_exists('id', $input['invitations'][$key]) && is_numeric($input['invitations'][$key]['id'])) { diff --git a/app/Http/Requests/Quote/UpdateQuoteRequest.php b/app/Http/Requests/Quote/UpdateQuoteRequest.php index 61be5679e705..93eac1f51289 100644 --- a/app/Http/Requests/Quote/UpdateQuoteRequest.php +++ b/app/Http/Requests/Quote/UpdateQuoteRequest.php @@ -77,6 +77,8 @@ class UpdateQuoteRequest extends Request $input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']); } + $input['id'] = $this->quote->id; + $this->replace($input); } } diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 40bc648246fb..bf84869ed935 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -71,6 +71,9 @@ class Credit extends BaseModel ]; protected $casts = [ + // 'date' => 'date:Y-m-d', + // 'due_date' => 'date:Y-m-d', + // 'partial_due_date' => 'date:Y-m-d', 'line_items' => 'object', 'backup' => 'object', 'updated_at' => 'timestamp', diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 590bd9fcff92..f21364d1b483 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -107,6 +107,9 @@ class Invoice extends BaseModel ]; protected $casts = [ + // 'date' => 'date:Y-m-d', + // 'due_date' => 'date:Y-m-d', + // 'partial_due_date' => 'date:Y-m-d', 'line_items' => 'object', 'backup' => 'object', 'updated_at' => 'timestamp', @@ -114,20 +117,13 @@ class Invoice extends BaseModel 'deleted_at' => 'timestamp', ]; - protected $with = [ - // 'company', - // 'client', - ]; + protected $with = []; protected $appends = [ 'hashed_id', 'status' ]; - protected $dates = [ - 'date', - ]; - const STATUS_DRAFT = 1; const STATUS_SENT = 2; const STATUS_PARTIAL = 3; diff --git a/app/Models/Quote.php b/app/Models/Quote.php index f344d0f1607d..498acaaf9d52 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -77,9 +77,9 @@ class Quote extends BaseModel ]; protected $casts = [ - 'date' => 'date:Y-m-d', - 'due_date' => 'date:Y-m-d', - 'partial_due_date' => 'date:Y-m-d', + // 'date' => 'date:Y-m-d', + // 'due_date' => 'date:Y-m-d', + // 'partial_due_date' => 'date:Y-m-d', 'line_items' => 'object', 'backup' => 'object', 'updated_at' => 'timestamp', @@ -87,6 +87,8 @@ class Quote extends BaseModel 'deleted_at' => 'timestamp', ]; + protected $dates = []; + const STATUS_DRAFT = 1; const STATUS_SENT = 2; const STATUS_APPROVED = 3; @@ -101,24 +103,32 @@ class Quote extends BaseModel public function getDateAttribute($value) { if (!empty($value)) { + info("parsing date"); return (new Carbon($value))->format('Y-m-d'); } + return $value; } public function getDueDateAttribute($value) { if (!empty($value)) { + + info("parsing due date"); return (new Carbon($value))->format('Y-m-d'); } + return $value; } public function getPartialDueDateAttribute($value) { if (!empty($value)) { + + info("parsing partial date"); return (new Carbon($value))->format('Y-m-d'); } + return $value; } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 02cd86de56ef..26657d78f107 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -194,6 +194,7 @@ class BaseRepository */ protected function alternativeSave($data, $model) { +// info(print_r($data,1)); $class = new ReflectionClass($model);