Delete values from dependant select

I have the following code:

Select::make('nations')
    ->relationship(name: 'nations', titleAttribute: 'name')
    ->searchable()
    ->multiple()
    ->required()
    ->preload()
    ->live(),

Select::make('championships')
    ->relationship(
        name: 'championships',
        titleAttribute: 'name',
        modifyQueryUsing: fn (Builder $query, Get $get) => $query->whereHas('nations', function ($subquery) use ($get) {
            $subquery->whereIn('nation_id', $get('nations'));
        }),
    )
    ->searchable()
    ->multiple()
    ->required()
    ->preload(),


It works correctly but if for example I delete a record from the first select, the related records from the second select are not deleted. How could I do it?

Thank you
Was this page helpful?