F
Filament12mo ago
Gush

big database select options not founding result

Hello, im trying to do a form with country, state, city selects, the first two work fine since are much less results but my city select form cant seem to work after certain countries down the list here is my code, i tried both ways
// Forms\Components\Select::make('city_id')
// ->label('City')
// ->options(fn (Get $get): Collection => City::query()
// ->where('state_id', $get('state_id'))
// ->pluck('name', 'id'))
// ->searchable()
// // ->preload()
// ->live()
// ->required(),
Forms\Components\Select::make('city_id')
->label('City')
->getSearchResultsUsing(fn (Get $get): array => City::where('state_id', $get('state_id'))->pluck('name', 'id')->toArray())
->getOptionLabelUsing(fn ($value): ?string => City::find($value)?->name)
->preload()
->searchable()
->live()
->required(),
// Forms\Components\Select::make('city_id')
// ->label('City')
// ->options(fn (Get $get): Collection => City::query()
// ->where('state_id', $get('state_id'))
// ->pluck('name', 'id'))
// ->searchable()
// // ->preload()
// ->live()
// ->required(),
Forms\Components\Select::make('city_id')
->label('City')
->getSearchResultsUsing(fn (Get $get): array => City::where('state_id', $get('state_id'))->pluck('name', 'id')->toArray())
->getOptionLabelUsing(fn ($value): ?string => City::find($value)?->name)
->preload()
->searchable()
->live()
->required(),
1 Reply
Gush
GushOP12mo ago
Schema::create('cities', function (Blueprint $table) {
$table->id();
$table->string('name')->index();
$table->foreignId('state_id')->nullable()->references('id')->on('states')->onDelete('cascade');
$table->timestamps();
});
Schema::create('cities', function (Blueprint $table) {
$table->id();
$table->string('name')->index();
$table->foreignId('state_id')->nullable()->references('id')->on('states')->onDelete('cascade');
$table->timestamps();
});
i already tried to "index" for what i understod of that concept
Want results from more Discord servers?
Add your server