Group Options in record Select in Relation Manager

Hello, I'm trying to achieve to group options in Select record input in AttachAction in Relation Manager, but I have an error :
Method Illuminate\Support\Collection::getQuery does not exist.
Method Illuminate\Support\Collection::getQuery does not exist.
`
Tables\Actions\AttachAction::make()
->recordSelectOptionsQuery(function (Builder $query) {

return $query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
});

})
Tables\Actions\AttachAction::make()
->recordSelectOptionsQuery(function (Builder $query) {

return $query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
});

})
In Database I have a column
season
season
and so I would like to group options by season when I choose a record to attach. In doc, (https://filamentphp.com/docs/3.x/forms/fields/select#grouping-options) to group options; values must be formatted like in example. Doing
dd($query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
}));
dd($query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
}));
I have the good format. Any help will be welcome. Thanks
4 Replies
yagrasdemonde
yagrasdemondeOP3mo ago
Anyone ? 🫢
awcodes
awcodes3mo ago
What does the dd look like?
yagrasdemonde
yagrasdemondeOP3mo ago
dd($query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
}));
dd($query->get()->groupBy('season')->map(function ($item) {
return $item->keyBy('id')->map(fn ($item) => $item->title);
}));
return this
yagrasdemonde
yagrasdemondeOP3mo ago
No description
Want results from more Discord servers?
Add your server