pavloniym/nova-options-selector

Multiple options selector field for Laravel Nova.

Downloads

2761

Stars

2

Version

v1.1.0

Nova Options Selector

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.

pavloniym

Author

pavloniym