//adding a single tag$yourModel->attachTag('tag 1');
//adding multiple tags$yourModel->attachTags(['tag 2', 'tag 3']);
//using an instance of \Spatie\Tags\Tag$yourModel->attach(\Spatie\Tags\Tag::findOrCreate('tag4'));
The tags will be stored in the tags-table. When using these functions we'll make sure that tags are unique and a model will have a tag attached only once.
//using a string$yourModel->detachTag('tag 1');
//using an array$yourModel->detachTags(['tag 2', 'tag 3']);
//using an instance of \Spatie\Tags\Tag$yourModel->detach(\Spatie\Tags\Tag::Find('tag4'));
Tags are stored in the tags table and can be managed with the included Spatie\Tags\Tag-model.
//create a tag$tag = Tag::create(['name' => 'my tag']);
//update a tag$tag->name = 'another tag';
$tag->save();
//use "findFromString" instead of "find" to retrieve a certain tag$tag = Tag::findFromString('another tag')
//create a tag if it doesn't exist yet$tag = Tag::findOrCreateFromString('yet another tag');
//delete a tag$tag->delete();