North
North
TLCTuto's Laravel Corner
Created by North on 6/23/2024 in #💡filament
State - City select fields
I have this code, got from the filament documentation
Select::make('state_id')
->searchable()
->label('Estado')
->native(false)
->preload()
->options(State::query()->pluck('name', 'id'))
->required(),
Select::make('city_id')
->label('Cidade')
->native(false)
->options(fn (Get $get): Collection => City::where('state_id', $get('state_id'))
->orderBy('name')
->pluck('name','id'))
->searchable()
->required(),
Select::make('state_id')
->searchable()
->label('Estado')
->native(false)
->preload()
->options(State::query()->pluck('name', 'id'))
->required(),
Select::make('city_id')
->label('Cidade')
->native(false)
->options(fn (Get $get): Collection => City::where('state_id', $get('state_id'))
->orderBy('name')
->pluck('name','id'))
->searchable()
->required(),
Honestly, it gets the job done, but the second select (which should return all cities from the selected state) I'm getting just a few cities, out of 150ish or more, is there a limitation related to searchable() or Select::class itself? is there a better option to this?
5 replies