Using datatables to render home dashboard

This commit is contained in:
Deon George
2018-06-19 22:31:49 +10:00
parent 7e503eb1bc
commit 1ac764f05e
17 changed files with 7637 additions and 141 deletions

View File

@@ -8,9 +8,41 @@ class Payment extends Model
{
protected $table = 'ab_payment';
protected $dates = ['date_payment'];
protected $with = ['account.country.currency','items'];
public function getPaymentDateAttribute()
protected $appends = [
'date_paid',
'total',
];
protected $visible = [
'date_paid',
'id',
'total',
];
public function account()
{
return $this->belongsTo(\App\User::class);
}
public function items()
{
return $this->hasMany(PaymentItem::class);
}
public function getDatePaidAttribute()
{
return $this->date_payment->format('Y-m-d');
}
public function getTotalAttribute()
{
return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt);
}
public function currency()
{
return $this->account->country->currency;
}
}