Download the PHP package shamilchoudhury/eloquent-tags without Composer
On this page you can find all versions of the php package shamilchoudhury/eloquent-tags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shamilchoudhury/eloquent-tags
More information about shamilchoudhury/eloquent-tags
Files in shamilchoudhury/eloquent-tags
Package eloquent-tags
Short Description A tagging package for Laravel Eloquent models
License
Informations about the package eloquent-tags
Eloquent-Tags
A tagging package for Laravel Eloquent models.
Requirements
This package requires Laravel 5.3 or higher and PHP 7.0 or higher.
Installation
-
Install the
shamilchoudhury/eloquent-tags
package via composer: -
Add the service provider to
providers
array inconfig/app.php
: - Use artisan to run the migration to create the required tags tables.
Setup your Models
To make a model taggable, use the Taggable trait:
Done. Now your model is "taggable"!
Usage
Tag your models with the tag()
method:
The tag()
method is additive, so you can easily add new tags to the existing ones:
Tag names are normalized to avoid duplicate tags:
You can easily grab tags associated with a model using their relationship:
Since this is a direct relationship, you can easily order tags by their count:
Convert all tags associated with a model to an array:
You can grab a model with specific tags using query scopes:
You can delete all current tags and add new tags with retag()
:
You can remove tags with untag()
:
Simply use untag()
to remove all tags:
You can grab tags based on their count using the orderable scopes:
License
Eloquent-tags is open-sourced software licensed under the MIT license.