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(),
]),
]),
]);
}
Solution:Jump to solution
You can also use Repeatable entry for array or relationship.. https://filamentphp.com/docs/3.x/infolists/entries/repeatable#overview
5 Replies
I am able to get the data by using pluck() TextEntry::make($this->product->brands->pluck('name'))
->listWithLineBreaks(),
Solution
You can also use Repeatable entry for array or relationship.. https://filamentphp.com/docs/3.x/infolists/entries/repeatable#overview
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.
Did you solved this or not?
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