mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 08:04:34 -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);
|
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)
|
public function __call($method, $params)
|
||||||
{
|
{
|
||||||
$entity = strtolower(class_basename($this));
|
$entity = strtolower(class_basename($this));
|
||||||
|
@ -95,28 +95,20 @@ class Credit extends BaseModel
|
|||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDueDateAttribute($value)
|
public function getDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPartialDueDateAttribute($value)
|
public function getPartialDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function assigned_user()
|
public function assigned_user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
||||||
|
@ -141,28 +141,20 @@ class Invoice extends BaseModel
|
|||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDueDateAttribute($value)
|
public function getDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPartialDueDateAttribute($value)
|
public function getPartialDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
@ -102,30 +102,19 @@ class Quote extends BaseModel
|
|||||||
|
|
||||||
public function getDateAttribute($value)
|
public function getDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDueDateAttribute($value)
|
public function getDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPartialDueDateAttribute($value)
|
public function getPartialDueDateAttribute($value)
|
||||||
{
|
{
|
||||||
if (!empty($value)) {
|
return $this->dateMutator($value);
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user