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(),
]),
]),
]);
}
{
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
You can also use Repeatable entry for array or relationship.. https://filamentphp.com/docs/3.x/infolists/entries/repeatable#overview