dyfun/tags

There is no license information available for the latest version (1.0) of this package.

Laravel tags package

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/dyfun/tags

1.0 2024-04-22 16:22 UTC

This package is not auto-updated.

Last update: 2026-01-13 01:23:00 UTC


README

This package is a simple tag package for Laravel. It allows you to add tags to any model in your Laravel application.

Installation

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

Usage

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"]);