is it possible to group select items from query database

is it possible to group select from this
Select::make('status')
    ->searchable()
    ->options([
        'In Process' => [
            'draft' => 'Draft',
            'reviewing' => 'Reviewing',
        ],
        'Reviewed' => [
            'published' => 'Published',
            'rejected' => 'Rejected',
        ],
    ])


but get the group list from query database like this with category hasmany sub category:

Forms\Components\Select::make('payment_type_list_id')
                        ->options([
                            category::query() => [
                                sub_category::query()]
                        ])


thank you!
Solution
Forms\Components\Select::make('payment_type_list_id')
->searchable()
->options(function () {
return PaymentTypeList::with('paymentType')
->get()
->groupBy('paymentType.name')
->mapWithKeys(function ($group, $key) {
return [$key => $group->pluck('name', 'id')];
});
});

probably you can try like this . havent test yet.
Was this page helpful?