| Package Data | |
|---|---|
| Maintainer Username: | AlexanderPoellmann |
| Package Create Date: | 2015-09-02 |
| Package Last Update: | 2023-02-21 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-25 15:03:26 |
| Package Statistics | |
|---|---|
| Total Downloads: | 2,898 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 7 |
| Total Watchers: | 1 |
| Total Forks: | 3 |
| Total Open Issues: | 0 |
Simple way to tag Eloquent models in Laravel 5.
This package is a work in progress, please use with care and feel free to report any issues or ideas you may have!
We've transferred this package to a new owner and therefor updated the namespaces to Lecturize\Tags. The config file is now config/lecturize.php.
Require the package from your composer.json file
"require": {
"lecturize/laravel-tags": "dev-master"
}
and run $ composer update or both in one with $ composer require lecturize/laravel-tags.
Next register the service provider and (optional) facade to your config/app.php file
'providers' => [
// ...
Cviebrock\EloquentSluggable\ServiceProvider::class,
Lecturize\Tags\TagsServiceProvider::class
];
$ php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"
$ php artisan vendor:publish --provider="Lecturize\Tags\TagsServiceProvider"
This will create a config/sluggable.php, a config/lecturize.php and a migration file, that you'll have to run like so:
$ php artisan migrate
First, add our HasTags trait to your model.
<?php namespace App\Models;
use Lecturize\Tags\Traits\HasTags;
class Post extends Model
{
use HasTags;
// ...
}
?>
$tags = $model->tags();
$tags = $model->hasTag('Check');
$tags = $model->tag('My First Tag');
$tags = $model->tag(['First', 'Second', 'Third']);
$tags = $model->untag('Remove');
$tags = $model->retag('A New Tag');
$tags = $model->retag(['Fourth', 'Fifth', 'Sixth']);
$tags = $model->detag();
$tags = $model->listTags();
This is a convenience method for $model->tags->pluck('tag')
There are two scopes included to fluently query models (e.g. Posts) with given tags.
$posts = Post::withTag('My First Tag')->get();
$posts = Post::withTags(['First', 'Second', 'Third'])->get();
Licensed under MIT license.
Handcrafted with love by Alexander Manfred Poellmann in Vienna & Rome.