helios-live/php-nova-spatie-tags-filter

A Laravel Nova filter.

Downloads

17

Stars

0

Version

v1.0.1

NovaSpatieTagsFilter

Works with Laravel Nova 4.
Borrowed heavily from https://github.com/Mahi-Mahi/SpatieTagsNovaFilter.

This package allows you to filter resources by tags.

Using the awesome Spatie/laravel-tags and vueform/multiselect

Installation

First you must install spatie/laravel-tags into your Laravel app. Here are the installation instructions for that package.

Next, you can install this package in to a Laravel app that uses Nova via composer:

composer require helios-live/php-nova-spatie-tags-filter

Usage

After the package has been installed with Composer, simply register the filter in your resource:

use HeliosLive\PhpNovaSpatieTagsFilter\PhpNovaSpatieTagsFilter;

class MyResource extends Resource
{
    /**
     * Get the filters available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function filters(Request $request)
    {
        return [
            (new PhpNovaSpatieTagsFilter)
                ->label('Tags')
                // ->placeholder('')
                ->withMeta([
                    'withAnyTags' => true, // true, false, "never"
                    'tag_type' => null
                ])
        ];
    }
}

License

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

helios-live

Author

helios-live