added attribute casting
This commit is contained in:
@ -28,6 +28,16 @@ class Transaction extends Model
|
||||
*/
|
||||
protected $fillable = ['company_id', 'type', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'document_id', 'contact_id', 'description', 'category_id', 'payment_method', 'reference', 'parent_id'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'amount' => 'double',
|
||||
'currency_rate' => 'double',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
@ -225,28 +235,6 @@ class Transaction extends Model
|
||||
$this->document_id = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
$this->attributes['amount'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert currency rate to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrencyRateAttribute($value)
|
||||
{
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert amount to double.
|
||||
*
|
||||
|
Reference in New Issue
Block a user