Select Relationship Modify Query Using

Hi everyone,

When I create an auction I select a car but the dropdown only shows the cars that don't belongs to another auction (I use modifyQueryUsing), so this works when I create.

The issue is when I try to update an auction, I cannot see my car selected in the dropdown list because that car already belongs to the same auction that I'm updating so how can I fix that?

Select::make('car_id')
  ->label('Car')
  ->relationship(
      name: 'car',
      titleAttribute: 'name',
      modifyQueryUsing: fn (Builder $query) =>             $query->whereDoesntHave('auction')
      )
  ->required(),
Was this page helpful?