Tag Module
withTag()
Get all the entities with one of the given tag(s). Optionally specify the column on which to perform the search operation, defaults to the slug
column.
Example in your repository :
// Get all files with either of the 2 tags
$files = $this->file->withTag(['your-first-tag', 'some-other-tag'])->get();
whereTag()
Get all the entities with the given tag(s). Optionally specify the column on which to perform the search operation, defaults to slug
column.
Example in your repository :
// Get all files with all given tags
$files = $this->file->whereTag(['your-first-tag', 'some-other-tag'])->get();
// Get all files with the given tag
$files = $this->file->whereTag('your-first-tag')->get();
allTags()
You can fetch all the tags for an entity by using the allTags()
method.
$tags = $file->allTags();
untag()
To remove all tags from your entity call the untag()
method on it.
$file->untag();
You can also pass in an array of tags (Tag
entity) to remove specific tags. You shouldn't have to call this yourself.