Laravel-tags
A powerful tagging package. Batteries included.
This package offers taggable behaviour for your models. After the package is installed the only thing you have to do is to add the HasTags
trait to an Eloquent model to make it taggable.
We didn't stop with the regular tagging capabilities you find in every package. Laravel Tags comes with batteries included. Out of the box it has support for translating tags, multiple tag types and sorting capabilities.
Here are some code examples:
$newsItem = NewsItem::create([
'name' => 'testModel',
'tags' => ['tag', 'tag2'],
]);
$newsItem->attachTag('tag3');
$newsItem->attachTags(['tag4', 'tag5']);
$newsItem->detachTag('tag3');
$newsItem->detachTags(['tag4', 'tag5']);
$newsItem->syncTags(['tag1', 'tag2']);
NewsItem::withAnyTags(['tag1', 'tag2']);
NewsItem::withAllTags(['tag1', 'tag2']);
$tag = Tag::findOrCreate('my tag');
$tag->setTranslation('fr', 'mon tag');
$tag->setTranslation('nl', 'mijn tag');
$tag->save();
$tag = Tag::findOrCreate('tag 1', 'my type');
$tag = Tag::findOrCreate('yet another tag');
$tag->slug;
$tag = Tag::findOrCreate('my tag');
$tag->order_column;
$tag2 = Tag::findOrCreate('another tag');
$tag2->order_column;
$tag->swapOrder($anotherTag);
Tag::containing('test');
##We have badges!