mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for date mutators
This commit is contained in:
parent
5daeab3895
commit
7fc54b7fa1
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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'])) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,7 @@ class BaseRepository
|
||||
*/
|
||||
protected function alternativeSave($data, $model)
|
||||
{
|
||||
// info(print_r($data,1));
|
||||
|
||||
$class = new ReflectionClass($model);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user