usamamuneerchaudhary/laravel-tagify
An Eloquent Tagging package for Laravel 10
3,306
22
| Install | |
|---|---|
composer require usamamuneerchaudhary/laravel-tagify |
|
| Latest Version: | 1.0.3 |
| PHP: | ^8.1 |
| License: | MIT |
| Last Updated: | Feb 25, 2023 |
| Links: | GitHub · Packagist |
Maintainer: usamamuneerchaudhary
Tagify is a simple Tagging Package for Laravel
Using this package, you can simply tag, untag or retag any existing model in your laravel app.
Here's a quick example of what you can do in your models to enable tagging:
- This package supports Laravel 10
- Minimum PHP v8.1 supported
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Usamamuneerchaudhary\LaravelTagify\Taggable;
class Lesson extends Model
{
use Taggable;
}
Installation
You can install the package via composer:
composer require usamamuneerchaudhary/laravel-tagify
Run Migrations
Once the package is installed, you can run migrations,
php artisan migrate
Service Provider
Don't forget to add the ServiceProvider in app.php:
Usamamuneerchaudhary\LaravelTagify\TagifyServiceProvider::class,
Usage & Some basic functions
Add Tags to a Model
$tags =['Laravel','PHP'];
$model->tag($tags);
Untag a tag
$model->untag(['Laravel]);
Untag all tags
$model->untag();
Re-tag a tag to a model
$model->retag(['Eloquent','mysql']);
Get all tags
$model->tags;
You can also use scopes to get tags associated likeso,
App\Model\Lesson::withAllTags(['laravel','php']); //will return if has all tags
App\Model\Lesson::withAnyTags(['laravel','php','python']); //will only return the ones associated, and ignore the
ones which are not.
App\Model\Lesson::hasTags(['laravel','php']); //check if a model has tags
Tests
composer test
Security
If you discover any security related issues, please email hello@usamamuneer.me instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.3 | ^8.1 | >=v10.1.4 | MIT | |
| 1.0.2 | ^8.1 | >=v10.1.4 | MIT | |
| 1.0.1 | ^8.1 | >=v10.1.4 | MIT | |
| 1.0.0 | ^8.1 | >=v10.1.4 |
