Skip to content

getSearchResultsUsing() not working when using relationship #15482

Answered by gregoryloichot
aryadilas asked this question in Help
Discussion options

You must be logged in to vote

Try something like:

Select::make('region')
->label('Direction')
->native(false)
->searchable()
->options(Region::query()->orderByName()->pluck('name', 'id'))
->getSearchResultsUsing(fn(string $search): array => Region::where('name', 'like', "%{$search}%")->pluck('name', 'id')->toArray())
->getOptionLabelUsing(fn($value): ?string => Region::find($value)?->name),

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aryadilas
Comment options

Answer selected by aryadilas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants