Download the PHP package robotsinside/laravel-tags without Composer
On this page you can find all versions of the php package robotsinside/laravel-tags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download robotsinside/laravel-tags
More information about robotsinside/laravel-tags
Files in robotsinside/laravel-tags
Package laravel-tags
Short Description A package for tagging Laravel Eloquent models.
License MIT
Informations about the package laravel-tags
Laravel Tags
A simple package for tagging Eloquent models in Laravel. This package is a sibling of Laravel Categories, which can be used to categorise Eloquent models. The API is the same as this one.
Installation
-
Install using Composer
- Register the service provider in
config/app.php
Auto-discovery is enabled, so this step can be skipped.
-
Publish the migrations
- Migrate the database. This will create two new tables;
tags
andtaggables
Usage
Use the RobotsInside\Tags\Taggable
trait in your models.
You are now ready to start tagging. Models can be tagged by passing an integer, array of integers, a model instance or a collection of models.
Untagging models is just as simple.
Scopes
Each time a RobotsInside\Tags\Models\Tag
is used, the count
column in the tags
table is incremented. When a tag is removed, the count is decremented until it is zero.
This packages comes with a number of pre-defined scopes to make queries against the count
column easier, namely >=
, >
, <=
and <
contstrains, for example:
Tag::usedGte(1);
Tag::usedGt(2);
Tag::usedLte(3);
Tag::usedLt(4);
In addition, a scope on the Taggable
model is provided to constrain records created within the given time frame. This scope supports human readable values including days
, months
and years
in both singular and plural formats, for example:
Taggable::taggedWithin('7 days');
Taggable::taggedWithin('1 month');
Taggable::taggedWithin('2 years');
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Rob Francken
- All Contributors
Coffee Time
Will work for :coffee::coffee::coffee:
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-tags with dependencies
illuminate/database Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0