added attribute casting
This commit is contained in:
		| @@ -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. | ||||
|      * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user