Pharaonic
Loading...

Methods

# tag

You can use any of this ways to assign a tag to the model.

1$article->tag(1, 2); // Tags IDs
2$article->tag([1, 2]); // Array of Tags IDs
3 
4$article->tag(Tag::all()); // Eloquent Collection of Tags
5 
6$article->tag($tag1, $tag2); // Models
7$article->tag([$tag1, $tag2]); // Array of Models

# detag

You can use any of this ways to detach a model from tags.

1$article->detag(1, 2); // Tags IDs
2$article->detag([1, 2]); // Array of Tags IDs
3 
4$article->detag(Tag::all()); // Eloquent Collection of Tags
5 
6$article->detag($tag1, $tag2); // Models
7$article->detag([$tag1, $tag2]); // Array of Models

# syncTags

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 IDs
2$article->syncTags([1, 3]); // Array of Tags IDs
3 
4$article->syncTags(Tag::all()); // Eloquent Collection of Tags
5 
6$article->syncTags($tag1, $tag3); // Models
7$article->syncTags([$tag1, $tag3]); // Array of Models