You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
609 B

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Transaction extends Model
{
protected $casts = [
'items' => 'array',
'customer' => 'array',
];
public function getRouteKeyName()
{
return 'invoice_no';
}
public function getItemsCountAttribute($value)
{
$pcsCount = 0;
foreach ($this->items as $item) {
$pcsCount += $item['qty'];
}
return count($this->items).' Item, '.$pcsCount.' Pcs';
}
public function getExchange()
{
return $this->payment - $this->total;
}
}