added attribute casting

This commit is contained in:
Denis Duliçi
2020-11-13 15:15:27 +03:00
parent 9deac6b1f3
commit 2d7c18bae5
13 changed files with 108 additions and 99 deletions

View File

@ -26,6 +26,16 @@ class Account extends Model
*/
protected $fillable = ['company_id', 'name', 'number', 'currency_code', 'opening_balance', 'bank_name', 'bank_phone', 'bank_address', 'enabled'];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'opening_balance' => 'double',
'enabled' => 'boolean',
];
/**
* Sortable columns.
*
@ -63,17 +73,6 @@ class Account extends Model
return $query->where('number', '=', $number);
}
/**
* Convert opening balance to double.
*
* @param string $value
* @return void
*/
public function setOpeningBalanceAttribute($value)
{
$this->attributes['opening_balance'] = (double) $value;
}
/**
* Get the current balance.
*