mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor date mutators
This commit is contained in:
parent
cb24a89d00
commit
da26a1f2f2
@ -50,6 +50,15 @@ class BaseModel extends Model
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
public function dateMutatorw($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function __call($method, $params)
|
||||
{
|
||||
$entity = strtolower(class_basename($this));
|
||||
|
@ -95,28 +95,20 @@ class Credit extends BaseModel
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getPartialDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
|
||||
public function assigned_user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
||||
|
@ -141,28 +141,20 @@ class Invoice extends BaseModel
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getPartialDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
@ -102,31 +102,20 @@ class Quote extends BaseModel
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
public function getPartialDueDateAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $this->dateMutator($value);
|
||||
}
|
||||
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user