eminiarts / nova-permissions

Laravel Nova Grouped Permissions
126 stars 66 forks source link

Usage of Checkboxes field #7

Open pktharindu opened 5 years ago

pktharindu commented 5 years ago

I'm trying to use the included Checkboxes field in another nova resource and I can't figure out how the options should be passed. Currently, my field looks like something like this which doesn't work:

Checkboxes::make(__('Foods'), 'foods')
    ->withGroups()
    ->options(collect(config('foods'))->map(function ($food, $key) {
        return [
             'group'  => ucfirst($food['group']),
             'option' => $key,
             'label'  => $food['name'],
        ];
    })->groupBy('group')->toArray()),

My config file looks something like this:

<?php

return [
    'apple' => [
        'name' => 'Apple',
        'group' => 'Fruit',
    ],

    'orange' => [
        'name' => 'Orange',
        'group' => 'Fruit',
    ],
    ...
];

Can you please show me how I should structure the config file and/or fields options to make this work?