How to exclude current relationship options from Select input using->relationship()?

                    Select::make('role_ids')
                        ->label('Gebruikersrollen')
                        ->columnSpan(2)
                        ->multiple()
                        ->options(Role::all()->pluck('name', 'id')),

The above code snippet works if I manually set the role_ids property at the model.

But using the relationship method it does not:
Select::make('roles')
    ->label('Gebruikersrollen')
    ->columnSpan(2)
    ->multiple()
    ->preload()
    ->relationship('roles', 'name'),


As you can see in the screenshot, the role 'Hoofdgebruiker' is selected but still listed as option. Is this intended or how can this be solved? I know I can probably fix it using getSearchResultsUsing but that feels like a workaround.

Thank you in advance!
image.png
Was this page helpful?