45 lines
797 B
PHP
45 lines
797 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Balance extends Model
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $attributes = [
|
|
'balance' => 0,
|
|
'total_revenue' => 0,
|
|
'total_expenses' => 0,
|
|
'transferable' => true,
|
|
'is_frozen' => false,
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'balance',
|
|
'total_expenses',
|
|
'total_revenue',
|
|
'transferable',
|
|
'is_frozen',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'transferable' => 'bool',
|
|
'is_frozen'=>'bool',
|
|
];
|
|
|
|
public function getBalanceFormatAttribute()
|
|
{
|
|
return trim_trailing_zeros(bcdiv($this->attributes['balance'], 100, 2));
|
|
}
|
|
}
|