Skip to content

Commit

Permalink
Added childItems to invoice item child
Browse files Browse the repository at this point in the history
  • Loading branch information
dumithsalinda committed Jan 5, 2025
1 parent 80d081b commit f76f3af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function make()

public function items()
{
return $this->hasMany(InvoiceItem::class);
return $this->hasMany(InvoiceItem::class)->rootWithChildren();
}


Expand Down
4 changes: 4 additions & 0 deletions src/Models/InvoiceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ public function childItems()
{
return $this->hasMany(InvoiceItem::class, 'parent_item_id');
}
public function scopeRootWithChildren($query)
{
$query->whereNull('parent_item_id')->with('childItems');
}
}

0 comments on commit f76f3af

Please sign in to comment.