pavloniym/nova-options-selector

Multiple options selector field for Laravel Nova.

v1.1.2 2024-07-29 17:29 UTC

This package is auto-updated.

Last update: 2024-10-29 17:58:48 UTC


README

Latest Version on Packagist

This Laravel Nova package adds an options selector to Nova's arsenal of fields.

Nova Options Selector

Requirements

  • php: >=8.0
  • laravel/nova: ^4.1

Installation

Install the package in a Laravel Nova project via Composer:

composer require pavloniym/nova-options-selector

Usage

Model field should be casted as array

use Pavloniym\OptionsSelector\OptionsSelector;

public function fields(Request $request)
{
    return [
      OptionsSelector::make('Permissions', 'permissions')
        ->options([
            [
                'group' => [
                    'title' => 'Account permissions',
                ],
                'entries' => [
                    [
                        'key' => 'account:update',
                        'title' => 'Update account',
                        'description' => 'User can update any account in database'
                    ],
                    [
                        'key' => 'account:selfDelete',
                        'title' => 'Delete self account'
                    ],
                ]
            ],
            // ...
        ])

        // Optional:
        ->searchable() // show search bar on form and detail views
        ->setGridColumnsGap(4)  // set gap between columns
        ->setGridColumnsWidth(250) // set grid columns width in pixels
        ->setMaxRowWidthOnIndex('200px') // set max with on index field
    ];
}

License

This project is open-sourced software licensed under the MIT license.