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

@@ -25,6 +25,16 @@ class Tax extends Model
*/
protected $fillable = ['company_id', 'name', 'rate', 'type', 'enabled'];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'rate' => 'double',
'enabled' => 'boolean',
];
/**
* Sortable columns.
*
@@ -101,17 +111,6 @@ class Tax extends Model
return $query->where($this->table . '.type', '<>', 'withholding');
}
/**
* Convert rate to double.
*
* @param string $value
* @return void
*/
public function setRateAttribute($value)
{
$this->attributes['rate'] = (double) $value;
}
/**
* Get the name including rate.
*