Merge Invoice and Bill into Document

This commit is contained in:
Burak Çakırel
2020-12-24 01:28:38 +03:00
parent 830cc05957
commit 0c1424db47
436 changed files with 31655 additions and 37350 deletions

View File

@ -3,6 +3,7 @@
namespace App\Models\Common;
use App\Abstracts\Model;
use App\Models\Document\Document;
use App\Traits\Currencies;
use App\Traits\Media;
use Bkwld\Cloner\Cloneable;
@ -61,14 +62,19 @@ class Item extends Model
return $this->hasMany('App\Models\Common\ItemTax');
}
public function document_items()
{
return $this->hasMany('App\Models\Document\DocumentItem');
}
public function bill_items()
{
return $this->hasMany('App\Models\Purchase\BillItem');
return $this->document_items()->where('type', Document::BILL_TYPE);
}
public function invoice_items()
{
return $this->hasMany('App\Models\Sale\InvoiceItem');
return $this->document_items()->where('type', Document::INVOICE_TYPE);
}
public function scopeName($query, $name)