Skip to content

Displore/Tags

Repository files navigation

Displore Tags

Latest Version on Packagist Quality Score

Basic tags for Laravel.

Install

$ php artisan displore:install tags

This does everything for you, from the Composer requirement to the addition of Laravel service providers.

Via Composer

$ 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,

Configuration

Run the following command to get the migrations.

$ php artisan vendor:publish --tag=displore.tags.migrations

Usage

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;

Change log

Please see changelog for more information what has changed recently.

Testing

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

Contributing

Please see contributing for details.

Credits

License

The EUPL License. Please see the License File for more information.

Releases

No releases published

Packages

No packages published

Languages