added attribute casting
This commit is contained in:
@ -24,6 +24,15 @@ class Contact extends Model
|
||||
*/
|
||||
protected $fillable = ['company_id', 'type', 'name', 'email', 'user_id', 'tax_number', 'phone', 'address', 'website', 'currency_code', 'reference', 'enabled'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
|
@ -19,6 +19,15 @@ class Dashboard extends Model
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'enabled'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
|
@ -28,6 +28,17 @@ class Item extends Model
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'description', 'sale_price', 'purchase_price', 'category_id', 'tax_id', 'enabled'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'sale_price' => 'double',
|
||||
'purchase_price' => 'double',
|
||||
'enabled' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
*
|
||||
@ -60,28 +71,6 @@ class Item extends Model
|
||||
return $query->where('name', '=', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sale price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setSalePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['sale_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert purchase price to double.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setPurchasePriceAttribute($value)
|
||||
{
|
||||
$this->attributes['purchase_price'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item id.
|
||||
*
|
||||
|
@ -19,7 +19,7 @@ class Report extends Model
|
||||
protected $fillable = ['company_id', 'class', 'name', 'description', 'settings'];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ class Widget extends Model
|
||||
protected $fillable = ['company_id', 'dashboard_id', 'class', 'name', 'sort', 'settings'];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
Reference in New Issue
Block a user