/home/techb158/ileadtechnology.com/SSM/app/Models/inventory
Edit: /home/techb158/ileadtechnology.com/SSM/app/Models/inventory/StockItem.php (1936B)
'array'];
protected $primaryKey = 'id';
protected $table = 'stock_items';
protected static $logName = 'stock_item';
protected static $logFillable = true;
protected static $logOnlyDirty = true;
protected static $ignoreChangedAttributes = ['updated_at'];
protected $appends = ['net_quantity'];
public function category()
{
return $this->belongsTo('App\Models\Inventory\StockCategory', 'stock_category_id');
}
public function getNetQuantityAttribute()
{
return $this->opening_quantity + $this->quantity;
}
public function getOption(string $option)
{
return array_get($this->options, $option);
}
public function scopeInfo($q)
{
return $q->with('category');
}
public function scopeFilterById($q, $id)
{
if (! $id) {
return $q;
}
return $q->where('id', '=', $id);
}
public function scopeFilterByName($q, $name, $s = 0)
{
if (! $name) {
return $q;
}
return ($s) ? $q->where('name', '=', $name) : $q->where('name', 'like', '%'.$name.'%');
}
public function scopeFilterByCode($q, $code, $s = 0)
{
if (! $code) {
return $q;
}
return ($s) ? $q->where('code', '=', $code) : $q->where('code', 'like', '%'.$code.'%');
}
}