document relationship should specify type of document

This commit is contained in:
Sevan Nerse
2020-12-28 11:36:09 +03:00
parent 3fa2ec8647
commit c78a5a0a4e
4 changed files with 5 additions and 6 deletions

View File

@ -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);