LaravelPackages.net
Acme Inc.
Toggle sidebar
scouser03/multi-select

A Multiselect field for Laravel Nova

15
1
1.4.0
About scouser03/multi-select

scouser03/multi-select is a Laravel package for a multiselect field for laravel nova. It currently has 1 GitHub stars and 15 downloads on Packagist (latest version 1.4.0). Install it with composer require scouser03/multi-select. Discover more Laravel packages by scouser03 or browse all Laravel packages to compare alternatives.

Last updated

A Multiselect field for Laravel Nova

Installation

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

composer require scouser03/multi-select

Usage

namespace App\Nova;

use Spatie\TagsField\Tags;
use Scouser03\MultiSelect\MultiSelect;

class BlogPost extends Resource
{
    // ...

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

            MultiSelect::make('select name with model', 'tags') //tags is relation name
                ->table('post_tag') //Relation table
                ->inputId('uuid') //Sets the id of the input element. default - id
                ->label('tag') // What key to use when generating option labels when each option is an object, default - name
                ->indexUpdateable(true) //when attach new tag to index resource
                ->model(Tag::class), //get all data with model

            MultiSelect::make('select name with query', 'tags')
                ->table('post_tag')
                ->label('tag')
                ->query(Tag::query()->take(3)->get()), //pass collection data

            // ...
        ];
    }
}

License

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

Comments