Nested relation

Hello, I have this structure: the order has multiple order items which are linked to a product table. Now in my orders list page I see all my orders and when I view one of them I use the repeater to show the ordered products. Since all the products info are on the products table how do I show them? I tried by calling the relationship name with the dot notation but none it's working.
Repeater::make('b2bOrderItems')
->relationship('b2bOrderItems')
->schema([
TextInput::make('sku'),
TextInput::make('product.description')
Repeater::make('b2bOrderItems')
->relationship('b2bOrderItems')
->schema([
TextInput::make('sku'),
TextInput::make('product.description')
The sku which is redundant on the order items table is working obviously, but the description is not. Thanks πŸ™‚
Solution:
@pboivin thanks but I already was in the Relation Manager resource. Luckily I managed to solve in this way: ```Repeater::make('b2bOrderItems') ->relationship('b2bOrderItems') ->schema([...
Jump to solution
3 Replies
Patrick Boivin
Patrick Boivinβ€’17mo ago
Have you tried with a relation manager? Do you think this could work for your use-case : https://filamentphp.com/docs/2.x/admin/resources/relation-managers
Solution
riccardogaleazzi
riccardogaleazziβ€’17mo ago
@pboivin thanks but I already was in the Relation Manager resource. Luckily I managed to solve in this way:
Repeater::make('b2bOrderItems')
->relationship('b2bOrderItems')
->schema([
TextInput::make('sku'),
Group::make([
TextInput::make('description')
])->relationship('product')
->columnSpan(1)
Repeater::make('b2bOrderItems')
->relationship('b2bOrderItems')
->schema([
TextInput::make('sku'),
Group::make([
TextInput::make('description')
])->relationship('product')
->columnSpan(1)
The Group class allows to specify a relationship and really important it has the columnSpan method to align the Group next to the other fields, otherwise it is full width and it breaks anything!
AlexAnder
AlexAnderβ€’17mo ago
Did any nested field You update.. works?
Want results from more Discord servers?
Add your server