rockbuzz/lara-tags is a Laravel package for tag management.
It currently has 0 GitHub stars and 2.490 downloads on Packagist (latest version 9.0.0).
Install it with composer require rockbuzz/lara-tags.
Discover more Laravel packages by rockbuzz
or browse all Laravel packages to compare alternatives.
Last updated
Tag management
PHP >=7.3
$ composer require rockbuzz/lara-tags
$ php artisan vendor:publish --provider="Rockbuzz\LaraTags\ServiceProvider" --tag="migrations"
$ php artisan migrate
Add the Taggable trait to the template for which you will have tags
use Rockbuzz\LaraTags\Traits\Taggable;
class Article extends Model
{
use Taggable;
}
use Rockbuzz\LaraTags\Models\Tag;
$tag = Tag::findFromSlug('slug'); //instance or null
$tag = Tag::findFromSlug('slug', 'type'); //instance or null
$article = new Article();
$article->tags(); //MorphToMany
$article->tags; //Collection
$article->tagsWithType('type'); //Collection
$article->hasTag('tag_name'); //boolean
$article->hasTag($tagInstance); //boolean
Scopes
Article::withAnyTags($arrayTags);
Article::withAnyTags($arrayTags, 'type');
or
Article::withAnyTags($arrayIdTags);
Article::withAnyTags($arrayIdTags, 'type');
or
Article::withAnyTags($arrayNameTags);
Article::withAnyTags($arrayNameTags, 'type');
The Lara Tags is open-sourced software licensed under the MIT license.