F
Filament13mo ago
Samir

Showing N:N relationship in Infolist added to Livewire

I have Product and Brand model which share many to many relationship. I created a SearchProduct livewire component which I am rendering on one public and other Filament Custom Page located in a Buyer Panel. I need to show all brands associated with a Product in a InfoList added to my Livewire component. I have pivot table and belongsToMany relationship defined in both models. Here is my Livewire code for Infolist. public function productInfolist(Infolist $infolist): Infolist { return $infolist ->record($this->product) ->schema([ TextEntry::make('name'), TextEntry::make('description'), Tabs::make('Label') ->tabs([ Tabs\Tab::make('Synonyms') ->schema([ TextEntry::make('syn') ->listWithLineBreaks(), ]), Tabs\Tab::make('Brands') ->schema([ TextEntry::make($this->product->brands) ->listWithLineBreaks(), ]), ]), ]); }
5 Replies
Samir
SamirOP13mo ago
I am able to get the data by using pluck() TextEntry::make($this->product->brands->pluck('name')) ->listWithLineBreaks(),
Solution
Samir
SamirOP13mo ago
Hey this was way easier... i have a question below simple json field cast to array ->schema([ TextEntry::make('syn') ->listWithLineBreaks(), ]), How to use Repeatable entry for this. I am trying to use like RepeatableEntry::make('syn')->schema([ TextEntry::make('syn') But i gives me list of empty entries.
Vp
Vp13mo ago
Did you solved this or not?
Samir
SamirOP13mo ago
No I have not been able to solve this. I marked the question solved for first part of listing my brands. I am also posting in new question thread. Here is the thread. https://discord.com/channels/883083792112300104/1171745049244073985
Want results from more Discord servers?
Add your server