scouser03 / nova4-multiselect

一个Laravel Nova字段。

1.4.0 2023-03-20 12:27 UTC

This package is auto-updated.

Last update: 2024-09-20 15:37:19 UTC


README

安装

首先,您必须使用composer将此包安装到使用Nova的Laravel应用程序中。

composer require scouser03/nova4-multiselect

用法

namespace App\Nova;

use Spatie\TagsField\Tags;
use Scouser03\Nova4Multiselect\Nova4Multiselect;

class BlogPost extends Resource
{
    // ...

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

            Nova4Multiselect::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

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

            // ...
        ];
    }
}

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件