Basic tags for Laravel.
Via Displore Core
$ php artisan displore:install tags
This does everything for you, from the Composer requirement to the addition of Laravel service providers.
$ composer require displore/tags
This requires the addition of the Tags service provider and Tags facade alias to config/app.php.
Displore\Tags\TagsServiceProvider::class,
and
Displore\Tags\Facades\Tagger::class,
Run the following command to get the migrations.
$ php artisan vendor:publish --tag=displore.tags.migrations
Tags can be added to every model. They optionally have a description and a category. The Tagger class is resolved by Laravel.
In order to make it work, your model(s) should use the trait Displore\Tags\Taggable
.
Some examples:
$task = Task::find(1);
Tagger::tag($task, 'Important');
// or...
$task->tag('Important');
Tagger::create('Important', 'Optional category', 'optional description');
Tagger::tagOrCreate($task, 'Very Important');
Tagger::untag($task, 'Important');
// or...
$task->untag('Important');
Tagger::syncTags($task, ['Important', 'Very Important']);
// or...
$task->syncTags(['Important', 'Very Important']);
$tagsForTask = $task->tags;
Please see changelog for more information what has changed recently.
The package comes with unit tests. In a Laravel application, with Laravel Packager:
$ php artisan packager:git *Displore Github url*
$ php artisan packager:tests Displore Tags
$ phpunit
Please see contributing for details.
The EUPL License. Please see the License File for more information.