Convenience methods

Tag Module


Scope: 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();

Scope: 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();

Get all tags for an entity: allTags()

You can fetch all the tags for an entity by using the allTags() method.

$tags = $file->allTags();

Delete tags for an entity: 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.

Mobile Analytics