Download the PHP package amitkolloldey/laravel-taggify without Composer
On this page you can find all versions of the php package amitkolloldey/laravel-taggify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amitkolloldey/laravel-taggify
More information about amitkolloldey/laravel-taggify
Files in amitkolloldey/laravel-taggify
Package laravel-taggify
Short Description Yet another eloquent tagging package for Laravel 7
License MIT
Informations about the package laravel-taggify
Laravel Taggify - Eloquent Tagging Package
This package will allow user to add Tagging system in the Laravel 7 application.
You can provide combination of string or id or model to create tags. It will check if a tag is already exists in the tags table. If not it will create a new tag and attach with the model. It also comes with some useful helpers and Scopes.
Composer Install
Run the migrations
Migrate The database tables
It will migrate tags
, taggables
tables
Setup your models
To creat a many to many polymorphic relation with your model and tags you need to use the Taggify
trait.
Usage
To attach/create new tags it uses addTags method. This method takes an array containing models or id or name of the tags you want to attach to your model and of course you can all use combination of these.
Attaching or Creating tags
Or
The name will generate a unique slug for the tag and will increment the count
column. The count
column will represent how many times the tag's being used.
Detaching given tags
The remove tags will detach the given tags and decrement the count
column.
Detaching all tags
It will detach all the tags associated with the model and decrement the count
column.
Re tag
It will detach Previous Tags and attach Given Tags and decrement the count
column.
Scopes
withAnyTag
Gets The Models Associated with Any Given Tags.
withAllTags
Finds The Models Where Given All Tags Are In Common.
popular
It will give the most popular tags based on count
column.
unPopular
Gets Less Used Tags based on count
column.
unUsed
Gets Unused Tags based on count
column.
usedMoreThan
Return tags that are used more than given times based on count
column.
usedLessThan
Return tags that are used less than given times based on count
column.
Helpers
The package comes with 2 useful helpers, which you can use throughout your application.
popular_tags_by_model
Gets Popular Tags In A Specific Model.
popular_tags
Gets Popular Tags In All Models
Inverse Relation in Tag Model
use items() method and give a model
Inverse Polymorphic Between Tag and A Model.
You can also add inverse relationship by extending the AmitKD\LaravelTaggify\Models\Tag
model
Credits
- Amit Kollol Dey - http://amitkolloldey.me
All versions of laravel-taggify with dependencies
illuminate/database Version >= 5.0|^6.0|^7.0
illuminate/support Version >= 5.0|^6.0|^7.0