Custom Select

Hey, how can I create a select with a model but also with groups like below
Select::make('status')
->searchable()
->options([
'In Process' => [
'draft' => 'Draft',
'reviewing' => 'Reviewing',
],
'Reviewed' => [
'published' => 'Published',
'rejected' => 'Rejected',
],
])
Select::make('status')
->searchable()
->options([
'In Process' => [
'draft' => 'Draft',
'reviewing' => 'Reviewing',
],
'Reviewed' => [
'published' => 'Published',
'rejected' => 'Rejected',
],
])
My current code is
Select::make('attribute')
->multiple()
->getSearchResultsUsing(fn (string $search): Collection =>
collect(Attribute::where('name', 'like', "%{$search}%")
->orWhere('group', 'like', "%{$search}%")
->limit(50)->get()
)->groupBy('group')->map(fn($items) => $items->pluck('name')->all())
)
Select::make('attribute')
->multiple()
->getSearchResultsUsing(fn (string $search): Collection =>
collect(Attribute::where('name', 'like', "%{$search}%")
->orWhere('group', 'like', "%{$search}%")
->limit(50)->get()
)->groupBy('group')->map(fn($items) => $items->pluck('name')->all())
)
But with this solution the groups are not shown only the names in the list
No description
10 Replies
GeRaged | Niklas
GeRaged | NiklasOPβ€’16mo ago
But I want Food properties as group above the 3
No description
Dennis Koch
Dennis Kochβ€’16mo ago
Does the first part work? Do we support groups right now? πŸ€”
GeRaged | Niklas
GeRaged | NiklasOPβ€’16mo ago
Yes
Dennis Koch
Dennis Kochβ€’16mo ago
Good to know. Haven't used it myself yet πŸ˜…
GeRaged | Niklas
GeRaged | NiklasOPβ€’16mo ago
Your name sounds german πŸ€”
Dennis Koch
Dennis Kochβ€’16mo ago
What if you add an ID $items->pluck('name', 'id')? Does that help? Maybe it's only supported on ->options() though
GeRaged | Niklas
GeRaged | NiklasOPβ€’16mo ago
The category is still not displayed
Dennis Koch
Dennis Kochβ€’16mo ago
I guess it's only supported for options() then
GeRaged | Niklas
GeRaged | NiklasOPβ€’16mo ago
😒
Want results from more Discord servers?
Add your server