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

@ -17,6 +17,16 @@ class Reconciliation extends Model
*/
protected $fillable = ['company_id', 'account_id', 'started_at', 'ended_at', 'closing_balance', 'reconciled'];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'closing_balance' => 'double',
'reconciled' => 'boolean',
];
/**
* Sortable columns.
*
@ -28,15 +38,4 @@ class Reconciliation extends Model
{
return $this->belongsTo('App\Models\Banking\Account');
}
/**
* Convert closing balance to double.
*
* @param string $value
* @return void
*/
public function setClosingBalanceAttribute($value)
{
$this->attributes['closing_balance'] = (double) $value;
}
}