FilamentF
Filament2y ago
SET

Relation Manager through relation

I have three models: Order, OrderItem and Invoice.
Order.php:
public function order_items(): hasMany
{
    return $this->hasMany(OrderItem::class);
} 

OrderItem.php:
public function invoices(): belongsToMany
{
    return $this->belongsToMany(Invoice::class)->withPivot([
        "quantity",
        "unit",
    ]);
}

Invoice.php
public function order_items(): belongsToMany
    {
        return $this->belongsToMany(OrderItem::class)->withPivot([
            "quantity",
            "unit",
        ]);
    }

Order items have no separate page, I fill order items with repeater on order page. How can I display invoices with relation manager on the same page (with orders)?
Was this page helpful?