Select multiple getSearchResultsUsing()

Hello, I have a problem when searching on a multiple select when I run it, it changes the intutile of the options by the ids and not the names.

Select::make('skills')->required()->multiple()->searchable()->getSearchResultsUsing(fn(string $search) => AlternativeOccupation::where('name', 'like', "{$search}%")->limit(50)->pluck('name', 'id'))->getOptionLabelUsing(fn($value): ?string => AlternativeOccupation::find($value)?->name),
Solution
Since you’re using multiple you need to use getOptionLabelsUsing with a “s” on Labels. You’ll need to change your closure as well to handle the array:
->getOptionLabelsUsing(fn ($values): array => YourModel::find($values)?->pluck('name', 'id')
Was this page helpful?