© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
ziolupo

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');
    }
    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(),
  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!
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create select with pivot relationship
FilamentFFilament / ❓┊help
3y ago
Save relationship with pivot attributes/columns
FilamentFFilament / ❓┊help
3y ago
Pivot Select using Relationship
FilamentFFilament / ❓┊help
2w ago
Repeater not saving pivot relationship
FilamentFFilament / ❓┊help
2y ago