bill scopes
This commit is contained in:
parent
a3372aeb63
commit
04173eae78
@ -117,6 +117,11 @@ class Bill extends Model
|
|||||||
return $query->where('status', '<>', 'paid');
|
return $query->where('status', '<>', 'paid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeNumber($query, $number)
|
||||||
|
{
|
||||||
|
return $query->where('bill_number', '=', $number);
|
||||||
|
}
|
||||||
|
|
||||||
public function onCloning($src, $child = null)
|
public function onCloning($src, $child = null)
|
||||||
{
|
{
|
||||||
$this->status = 'draft';
|
$this->status = 'draft';
|
||||||
|
@ -34,7 +34,7 @@ class BillItem extends Model
|
|||||||
|
|
||||||
public function item()
|
public function item()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Common\Item');
|
return $this->belongsTo('App\Models\Common\Item')->withDefault(['name' => trans('general.na')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function taxes()
|
public function taxes()
|
||||||
|
@ -4,11 +4,11 @@ namespace App\Models\Purchase;
|
|||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
use App\Traits\Currencies;
|
use App\Traits\Currencies;
|
||||||
|
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||||
|
|
||||||
class BillItemTax extends Model
|
class BillItemTax extends Model
|
||||||
{
|
{
|
||||||
|
use Currencies, BelongsToThrough;
|
||||||
use Currencies;
|
|
||||||
|
|
||||||
protected $table = 'bill_item_taxes';
|
protected $table = 'bill_item_taxes';
|
||||||
|
|
||||||
@ -24,9 +24,14 @@ class BillItemTax extends Model
|
|||||||
return $this->belongsTo('App\Models\Purchase\Bill');
|
return $this->belongsTo('App\Models\Purchase\Bill');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function item()
|
||||||
|
{
|
||||||
|
return $this->belongsToThrough('App\Models\Common\Item', 'App\Models\Purchase\BillItem', 'bill_item_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function tax()
|
public function tax()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Setting\Tax');
|
return $this->belongsTo('App\Models\Setting\Tax')->withDefault(['name' => trans('general.na')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user