Download the PHP package robotsinside/laravel-categories without Composer
On this page you can find all versions of the php package robotsinside/laravel-categories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download robotsinside/laravel-categories
More information about robotsinside/laravel-categories
Files in robotsinside/laravel-categories
Package laravel-categories
Short Description A package for categorising Laravel Eloquent models.
License MIT
Informations about the package laravel-categories
Laravel Categories
A simple package for categorising Eloquent models in Laravel. This package is a sibling of Laravel Tags, which can be used to tag Eloquent models. The API is the same as this one.
Table of contents
- Installation
- Usage
- Scopes
- Security
- Credits
- Coffee Time
- License
Installation
-
Install using Composer
- Optionally 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;
categories
andcategorisables
Usage
Use the RobotsInside\Categories\Categorisable
trait in your models.
You are now ready to categorise your models. Models can be categorised by passing an integer, array of integers, a model instance or a collection of models.
Uncategorising models is just as simple.
Scopes
Each time a RobotsInside\Categories\Models\Category
is used, the count
column in the categories
table is incremented. When a category 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:
Category::usedGte(1);
Category::usedGt(2);
Category::usedLte(3);
Category::usedLt(4);
The RobotsInside\Categories\Models\Categorisable
model contains a scope to constrain records created within a given time frame. This scope supports human readable values including days
, months
and years
in both singular and plural formats, for example:
Categorisable::categorisedWithin('7 days');
Categorisable::categorisedWithin('1 month');
Categorisable::categorisedWithin('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-categories with dependencies
illuminate/database Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0