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.
`

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
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);
    }));

I have the good format.

Any help will be welcome.

Thanks
Was this page helpful?