Select::make('location_id')
->label(__('inputs.label.car_location'))
->placeholder(__('inputs.placeholder.car_location'))
->rules('required|exists:locations,id')
->required()
->searchDebounce(300)
->getSearchResultsUsing(function (string $search) {
return Location::where('county', 'like', "%{$search}%")
->orWhere('name', 'like', "%{$search}%")
->limit(25)
->orderBy('county')
->orderBy('name')
->get()
->mapWithKeys(function (Location $location) {
return [$location->id => "$location->name | $location->county"];
})
->toArray();
})
->getOptionLabelUsing(function (string $value) {
if (!$location = Location::find($value)) {
return null;
}
return "$location->name | $location->county";
})
->searchable()
->searchPrompt(__('inputs.location_search'))
Select::make('location_id')
->label(__('inputs.label.car_location'))
->placeholder(__('inputs.placeholder.car_location'))
->rules('required|exists:locations,id')
->required()
->searchDebounce(300)
->getSearchResultsUsing(function (string $search) {
return Location::where('county', 'like', "%{$search}%")
->orWhere('name', 'like', "%{$search}%")
->limit(25)
->orderBy('county')
->orderBy('name')
->get()
->mapWithKeys(function (Location $location) {
return [$location->id => "$location->name | $location->county"];
})
->toArray();
})
->getOptionLabelUsing(function (string $value) {
if (!$location = Location::find($value)) {
return null;
}
return "$location->name | $location->county";
})
->searchable()
->searchPrompt(__('inputs.location_search'))