Relationship with pivot
I have the following problem.
I have two models, Winery and Exhibition with a many-to-many relationship. The relationship has an added pivot attribute:
public function exhibitions(): BelongsToMany {
return $this->belongsToMany(Exhibition::class)->withPivot('with_masterclass');
}
in my winery resource I have a SELECT where I choose the Exhibition:
Forms\Components\Select::make('exhibitions')
->relationship('exhibitions', 'country')
->options(Exhibition::where('active', '=', 1)->get()->pluck('name', 'id'))
->native(false)
->preload()
->multiple(),
And this is working. I select the exhibitions and when I save larevel/filament is populating the exhibition_winery table.
The problem is that I would like another SELECT, identical to the previous one where I can choose the masterclasses and this should set to True the pivot field 'with_masterclass'.
From the UI point of view you can see in the attached image what I would like to achieve.
Thank you!0 Replies