how to change selectfilter options based on another selectfilter?

Hello, I have this city and district select options. In form, I can bring districts that belongs to the city. How can I perform same operation in SelectFilter component. I have read documents but couldn't find the solution

Select::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->searchable()
    ->preload()
    ->required()
    ->live()
    ->afterStateUpdated(fn($state, $set) => $set('district_id', null)),

Select::make('district_id')
    ->label('İlçe')
    ->options(function ($get) {
        $cityId = $get('city_id');
        if ( ! $cityId) {
            return [];
        }

        return District::where('city_id', $cityId)
            ->orderBy('name')
            ->pluck('name', 'id');
    })
    ->searchable()
    ->preload()
    ->disabled(fn($get) => ! $get('city_id')),


SelectFilter::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->indicator('Şehir')
    ->searchable()
    ->preload(),
SelectFilter::make('district_id')
    ->label('İlçe')
    ->relationship('district', 'name')
    ->indicator('İlçe')
    ->searchable()
    ->preload(),
Was this page helpful?