document relationship should specify type of document
This commit is contained in:
		@@ -17,7 +17,7 @@ class DocumentHistory extends Model
 | 
			
		||||
 | 
			
		||||
    public function document()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document');
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function scopeType(Builder $query, string $type)
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ class DocumentItem extends Model
 | 
			
		||||
 | 
			
		||||
    public function document()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document');
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function item()
 | 
			
		||||
@@ -126,7 +126,7 @@ class DocumentItem extends Model
 | 
			
		||||
        $tax_ids = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->taxes as $tax) {
 | 
			
		||||
            $tax_ids[] = (string)$tax->tax_id;
 | 
			
		||||
            $tax_ids[] = (string) $tax->tax_id;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->setAttribute('tax_ids', $tax_ids);
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,6 @@ use App\Abstracts\Model;
 | 
			
		||||
use App\Traits\Currencies;
 | 
			
		||||
use Illuminate\Database\Eloquent\Builder;
 | 
			
		||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
 | 
			
		||||
use Znck\Eloquent\Relations\BelongsToThrough as BelongsToThroughRelation;
 | 
			
		||||
use Znck\Eloquent\Traits\BelongsToThrough;
 | 
			
		||||
 | 
			
		||||
class DocumentItemTax extends Model
 | 
			
		||||
@@ -28,7 +27,7 @@ class DocumentItemTax extends Model
 | 
			
		||||
 | 
			
		||||
    public function document()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document');
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function item()
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ class DocumentTotal extends Model
 | 
			
		||||
 | 
			
		||||
    public function document()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document');
 | 
			
		||||
        return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function scopeType(Builder $query, string $type)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user