getSearchResultsUsing() not working when using relationship #15482
-
PackageForm builder Package Versionv3.2 How can we help you?
Why is getSearchResultsUsing not working when using relationships? I want to customize the query, but dd() doesn't even show up. |
Beta Was this translation helpful? Give feedback.
Answered by
gregoryloichot
Jan 31, 2025
Replies: 1 comment 1 reply
-
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), |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aryadilas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try something like: