File: /var/www/wsklad/app/Inventoryline.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Inventoryline extends Model
{
protected $fillable = [
'inventory_id',
'appInventoryId',
'occ',
'code',
'name',
'lot',
'lotDate',
'expDate',
'merka1',
'fkoef',
'permitNumber',
'orderQty',
'schetQty',
'matSkladQty',
'orderMerka',
'newLot',
'date',
'price',
];
protected $table = 'inventory_lines';
public function inventory()
{
return $this->belongsTo('App\Inventory');
}
protected function getQtyDiffAttribute()
{
return $this->matSkladQty - $this->schetQty == 0 ? 0 : number_format($this->matSkladQty - $this->schetQty, 3, '.', '');
}
protected function getAmountAttribute()
{
return $this->matSkladQty > $this->schetQty ? ( $this->matSkladQty - $this->schetQty) * $this->price : 0;
}
protected $appends = [
'amount',
'qtyDiff'
];
}