mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 17:34:36 -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'))
|
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;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -83,6 +83,8 @@ class UpdateCreditRequest extends FormRequest
|
|||||||
|
|
||||||
$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['id'] = $this->credit->id;
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,9 @@ class UpdateInvoiceRequest extends Request
|
|||||||
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']);
|
||||||
}
|
}
|
||||||
|
info($input['due_date']);
|
||||||
|
//unset($input['due_date']);
|
||||||
|
//unset($input['date']);
|
||||||
|
|
||||||
if (isset($input['invitations'])) {
|
if (isset($input['invitations'])) {
|
||||||
foreach ($input['invitations'] as $key => $value) {
|
foreach ($input['invitations'] as $key => $value) {
|
||||||
|
@ -77,6 +77,8 @@ class UpdateQuoteRequest extends Request
|
|||||||
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$input['id'] = $this->quote->id;
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,9 @@ class Credit extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
// 'date' => 'date:Y-m-d',
|
||||||
|
// 'due_date' => 'date:Y-m-d',
|
||||||
|
// 'partial_due_date' => 'date:Y-m-d',
|
||||||
'line_items' => 'object',
|
'line_items' => 'object',
|
||||||
'backup' => 'object',
|
'backup' => 'object',
|
||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
|
@ -107,6 +107,9 @@ class Invoice extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
// 'date' => 'date:Y-m-d',
|
||||||
|
// 'due_date' => 'date:Y-m-d',
|
||||||
|
// 'partial_due_date' => 'date:Y-m-d',
|
||||||
'line_items' => 'object',
|
'line_items' => 'object',
|
||||||
'backup' => 'object',
|
'backup' => 'object',
|
||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
@ -114,20 +117,13 @@ class Invoice extends BaseModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $with = [
|
protected $with = [];
|
||||||
// 'company',
|
|
||||||
// 'client',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
'hashed_id',
|
'hashed_id',
|
||||||
'status'
|
'status'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
|
||||||
'date',
|
|
||||||
];
|
|
||||||
|
|
||||||
const STATUS_DRAFT = 1;
|
const STATUS_DRAFT = 1;
|
||||||
const STATUS_SENT = 2;
|
const STATUS_SENT = 2;
|
||||||
const STATUS_PARTIAL = 3;
|
const STATUS_PARTIAL = 3;
|
||||||
|
@ -77,9 +77,9 @@ class Quote extends BaseModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'date' => 'date:Y-m-d',
|
// 'date' => 'date:Y-m-d',
|
||||||
'due_date' => 'date:Y-m-d',
|
// 'due_date' => 'date:Y-m-d',
|
||||||
'partial_due_date' => 'date:Y-m-d',
|
// 'partial_due_date' => 'date:Y-m-d',
|
||||||
'line_items' => 'object',
|
'line_items' => 'object',
|
||||||
'backup' => 'object',
|
'backup' => 'object',
|
||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
@ -87,6 +87,8 @@ class Quote extends BaseModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $dates = [];
|
||||||
|
|
||||||
const STATUS_DRAFT = 1;
|
const STATUS_DRAFT = 1;
|
||||||
const STATUS_SENT = 2;
|
const STATUS_SENT = 2;
|
||||||
const STATUS_APPROVED = 3;
|
const STATUS_APPROVED = 3;
|
||||||
@ -101,24 +103,32 @@ class Quote extends BaseModel
|
|||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
info("parsing date");
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDueDateAttribute($value)
|
public function getDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
|
||||||
|
info("parsing due date");
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPartialDueDateAttribute($value)
|
public function getPartialDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
|
||||||
|
info("parsing partial date");
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ class BaseRepository
|
|||||||
*/
|
*/
|
||||||
protected function alternativeSave($data, $model)
|
protected function alternativeSave($data, $model)
|
||||||
{
|
{
|
||||||
|
// info(print_r($data,1));
|
||||||
|
|
||||||
$class = new ReflectionClass($model);
|
$class = new ReflectionClass($model);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user