You can use any of this ways to assign a tag to the model.
1$article->tag(1, 2); // Tags IDs2$article->tag([1, 2]); // Array of Tags IDs3 4$article->tag(Tag::all()); // Eloquent Collection of Tags5 6$article->tag($tag1, $tag2); // Models7$article->tag([$tag1, $tag2]); // Array of Models
You can use any of this ways to detach a model from tags.
1$article->detag(1, 2); // Tags IDs2$article->detag([1, 2]); // Array of Tags IDs3 4$article->detag(Tag::all()); // Eloquent Collection of Tags5 6$article->detag($tag1, $tag2); // Models7$article->detag([$tag1, $tag2]); // Array of Models
You can use any of this ways to detach a model from all unnecessary tags and attach/keep it to all necessary tags.
1$article->syncTags(1, 3); // Tags IDs2$article->syncTags([1, 3]); // Array of Tags IDs3 4$article->syncTags(Tag::all()); // Eloquent Collection of Tags5 6$article->syncTags($tag1, $tag3); // Models7$article->syncTags([$tag1, $tag3]); // Array of Models