filamentphp / spatie-laravel-tags-plugin by DanHarrin

Filament support for `spatie/laravel-tags`.
359,504
20
3
Package Data
Maintainer Username: DanHarrin
Package Create Date: 2021-08-25
Package Last Update: 2024-04-28
Home Page: https://github.com/filamentphp/filament
Language: PHP
License: MIT
Last Refreshed: 2024-04-29 15:00:10
Package Statistics
Total Downloads: 359,504
Monthly Downloads: 29,099
Daily Downloads: 1,143
Total Stars: 20
Total Watchers: 3
Total Forks: 9
Total Open Issues: 0

Filament Spatie Tags Plugin

Installation

Install the plugin with Composer:

composer require filament/spatie-laravel-tags-plugin:"^3.1" -W

If you haven't already done so, you need to publish the migration to create the tags table:

php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-migrations"

Run the migrations:

php artisan migrate

You must also prepare your Eloquent model for attaching tags.

For more information, check out Spatie's documentation.

Form component

This guide assumes that you've already set up your model attach tags as per Spatie's documentation.

You may use the field in the same way as the original tags input field:

use Filament\Forms\Components\SpatieTagsInput;

SpatieTagsInput::make('tags')

The field will automatically load and save its tags to your model. To set this functionality up, you must also follow the instructions set out in the field relationships section. If you're using the Panel Builder, you can skip this step.

Optionally, you may pass a type() allows you to group tags into collections:

use Filament\Forms\Components\SpatieTagsInput;

SpatieTagsInput::make('tags')
    ->type('categories')

The tags input supports all the customization options of the original tags input component.

Table column

This guide assumes that you've already set up your model attach tags as per Spatie's documentation.

To use the tags column:

use Filament\Tables\Columns\SpatieTagsColumn;

SpatieTagsColumn::make('tags')

Optionally, you may pass a type():

use Filament\Tables\Columns\SpatieTagsColumn;

SpatieTagsColumn::make('tags')
    ->type('categories')

The type allows you to group tags into collections.

The tags column supports all the customization options of the original tags column.

Infolist entry

This guide assumes that you've already set up your model attach tags as per Spatie's documentation.

To use the tags entry:

use Filament\Infolists\Components\SpatieTagsEntry;

SpatieTagsEntry::make('tags')

Optionally, you may pass a type():

use Filament\Infolists\Components\SpatieTagsEntry;

SpatieTagsEntry::make('tags')
    ->type('categories')

The type allows you to group tags into collections.

The tags entry supports all the customization options of the text entry.