This package is a simple tag package for Laravel. It allows you to add tags to any model in your Laravel application.
You can install the package via composer:
composer require dyfun/tags
add the service provider to your config/app.php file:
'providers' => [
...
Dyfun\Tags\TagsServiceProvider::class,
...
];
run
php artisan migrate
Apply HasTags trait to a model
<?php
use Illuminate\Database\Eloquent\Model;
use Dyfun\Tags\HasTags;
class File extends Model
{
use HasTags;
...
}
Example:
$file = File::find(1);
$file->attachTag("apple");
$file->attachTags(["apple", "orange", "watermelon"]);
$file->detachTag("apple");
$file->detachTags(["apple", "orange"]);