scouser03/group-checkbox

A Laravel Nova field.

1.2.3 2022-11-29 12:26 UTC

This package is auto-updated.

Last update: 2024-10-29 06:46:58 UTC


README

Installation

First you must install this package in to a Laravel app that uses Nova via composer:

composer require scouser03/group-checkbox

Usage

namespace App\Nova;

use Scouser03\GroupCheckbox\GroupCheckbox;


class BlogPost extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            GroupCheckbox::make(__('Permissions'), 'prepared_permissions')
                ->withGroups()
                ->options(ModelsPermission::all()->map(function ($permission, $key) {
                return [
                    'group'  => __(ucfirst($permission->group)),
                    'option' => $permission->name,
                    'label'  => __($permission->name),
                ];
            })->groupBy('group')->toArray()),

            // ...
        ];
    }
}

License

The MIT License (MIT). Please see License File for more information.