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(),


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?
Solution
Select::make('author_id')
    ->searchable()
    ->getSearchResultsUsing(fn (string $search): array => User::where('name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray())
    ->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name),
Was this page helpful?