PHPackages                             putheng/taggy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. putheng/taggy

ActiveLibrary[Database &amp; ORM](/categories/database)

putheng/taggy
=============

An Eloquent tagging package for Laravel

1.0(7y ago)04PHPPHP &gt;=7.0

Since Jan 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/putheng/taggy)[ Packagist](https://packagist.org/packages/putheng/taggy)[ RSS](/packages/putheng-taggy/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Installation
------------

[](#installation)

Require this package with composer. It is recommended to only require the package for development.

```
composer require putheng/taggy

```

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

### Setting up from scratch

[](#setting-up-from-scratch)

#### Laravel 5.5+:

[](#laravel-55)

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

```
Putheng\Taggy\TaggyServiceProvider::class,
```

#### The schema

[](#the-schema)

For Laravel 5 migration

```
php artisan migrate
```

#### The model

[](#the-model)

Your model should use `Putheng\Taggy\TaggableTrait` trait to enable tags:

```
use Putheng\Taggy\TaggableTrait;

class Lession extends Model {
    use TaggableTrait;
}
```

Usage
-----

[](#usage)

#### Seed

[](#seed)

Seed the `tags` table

```
use Putheng\Taggy\Models\Tag;

$tags = [
	[
		'name' => 'PHP',
		'slug' => str_slug('PHP')
	],
	[
		'name' => 'Laravel',
		'slug' => str_slug('Laravel')
	],
	[
		'name' => 'Testing',
		'slug' => str_slug('Testing')
	],
	[
		'name' => 'Redis',
		'slug' => str_slug('Redis')
	],
];

Tag::insert($tags);
```

#### Tag a lession

[](#tag-a-lession)

Create a new lession and tags

```
use App\Lession;

$lession = new Lession;
$lession->title = 'a new lession';
$lession->save();

# name or slug version of value in tags table
$lession->tag(['Laravel', 'php']);

# tag from a collections of model
$tags = Putheng\Taggy\Models\Tag::whereIn('slug', ['php', 'laravel'])->get();
$lession->tag($tags);

# tag from a model
$tag = Putheng\Taggy\Models\Tag::where('name', 'Laravel')->first();
$lession->tag($tag);
```

Tag to an existing lessions

```
$lession = Lession::find(1);
$lession->tag(['Redis']);
```

Untag from a lession

```
$lession = Lession::find(1);
$lession->untag(['Redis']);
```

Retag from a lession, will remove all tags from lession and retag again

```
$lession = Lession::find(1);
$lession->retag(['Redis']);
```

Show tags of a lession

```
$lession = Lession::find(1);

# return collection of tags
$tags = $lession->tags;
```

Get lessions of any tags

```
# get lessions of any tags from array of tags's slug
$lessions = Lession::withAnyTag(['php', 'laravel']);

# return collection of lession
$lessions->get();
```

Get lessions of all tags

```
# get lessions of all tags from array of tags's slug
$lessions = Lession::withAllTags(['php', 'laravel']);

# return collection of lession
$lessions->get();
```

Get lessions has tags

```
# get lessions that has tags from array of tags's slug
$lessions = Lession::hasTags(['php', 'laravel']);

# return collection of lession
$lessions->get();
```

A scope to retrieve any tags where the count

```
use Putheng\Taggy\Models\Tag;

# is greater than or equal to the given value.
$tags = Tag::useGte();

# is greater than to the given value.
$tags = Tag::useGt();

# is less than or equal to the given value.
$tags = Tag::useLte();

# is less than the given value.
$tags = Tag::useLt();
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2675d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a517c33df877331a2ef37a0b9bfef3ffed53756b3ebb3c33f4a8713c075a9ec?d=identicon)[putheng](/maintainers/putheng)

---

Top Contributors

[![putheng](https://avatars.githubusercontent.com/u/19757130?v=4)](https://github.com/putheng "putheng (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/putheng-taggy/health.svg)

```
[![Health](https://phpackages.com/badges/putheng-taggy/health.svg)](https://phpackages.com/packages/putheng-taggy)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
