https://github.com/ishifoev/taggy
An Eloquent tagging package for laravel
https://github.com/ishifoev/taggy
laravel php taggy
Last synced: 10 months ago
JSON representation
An Eloquent tagging package for laravel
- Host: GitHub
- URL: https://github.com/ishifoev/taggy
- Owner: ishifoev
- Created: 2020-10-23T04:21:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-05T04:36:54.000Z (over 5 years ago)
- Last Synced: 2025-06-06T02:08:16.910Z (about 1 year ago)
- Topics: laravel, php, taggy
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Laravel Taggy
[](
https://travis-ci.org/github/AlexMalikov94/taggy
)
[](//packagist.org/packages/amalikov/taggy)
[](//packagist.org/packages/amalikov/taggy)
[](//packagist.org/packages/amalikov/taggy)
[](//packagist.org/packages/amalikov/taggy)
An Eloquent tagging package for Laravel
## Installation
Install the package through [Composer](http://getcomposer.org/).
Run the Composer require command from the Terminal:
composer require amalikov/taggy
The final steps for you are to add the service provider of the package and alias the package. To do this open your `config/app.php` file.
`Amalikov\Taggy\TaggyServiceProvider::class`
Go to the terminal in folder that you are migrate the `tags` and `taggable` tables:
```php artisan migrate```
## Usage
Add the `TaggableTrait` trait to a model you like to use `tags` on.
```
use Amalikov\Taggy\TaggableTrait;
class YourEloquentModel extends Model
{
use TaggableTrait;
}
```
Create a tags data for table that you use for example in controller or whatever place you want:
```
use Illuminate\Support\Str;
$tags = Tag::create([
'name' => 'Tag Name',
'slug' => Str::slug('Tag Name')
]);
```
You just need to pass the data that working with the models
```
$model = new YourEloquentModel;
$model->title = 'Test';
$model->save();
```
## Set a new tags
You can set a new tags like this:
```
$model->tag(['your_tag_name']);
````
## Untag existing tags
You can untag existing tag
```
$model->untag(['your_tag_name']);
````
## Untag all tags
```
$model->untag();
````
## Retag existing tag
```
$model->retag(['your_tag_name']);
````