PHPackages                             blamodex/laravel-tags - 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. blamodex/laravel-tags

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

blamodex/laravel-tags
=====================

A simple, Laravel-ready tagging package for rapid prototyping and lightweight use cases.

v1.0.0(5mo ago)154MITPHPPHP ^8.2CI passing

Since Dec 11Pushed 5mo agoCompare

[ Source](https://github.com/blamodex/laravel-tags)[ Packagist](https://packagist.org/packages/blamodex/laravel-tags)[ Docs](https://github.com/blamodex/laravel-tags)[ RSS](/packages/blamodex-laravel-tags/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (3)Used By (0)

Blamodex Laravel Tags
=====================

[](#blamodex-laravel-tags)

[![Latest Version on Packagist](https://camo.githubusercontent.com/884992d8b938fc5d0c07e140f5c89a23c5be738ee36bcee6d06aee405e74e4ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c616d6f6465782f6c61726176656c2d746167732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/blamodex/laravel-tags)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0bf9af5e40e59b7a2c67d935cdd44570ce6e17623d1c0458bb94a08b1730ad05/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626c616d6f6465782f6c61726176656c2d746167732f63692e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/blamodex/laravel-tags/actions)[![Total Downloads](https://camo.githubusercontent.com/f135484ca0e5bd6de4cace33cd0bb76b349f40a80c071dfa951992a5588c90af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c616d6f6465782f6c61726176656c2d746167732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/blamodex/laravel-tags)[![License](https://camo.githubusercontent.com/1b01ef0024ba0866c115986b895301f657c1b21fc29f05c4844b7f2e8d89204d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)[![Laravel](https://camo.githubusercontent.com/28258179aab3740537de18650134eb68e8c5f1f7396109f5bcfd29ddf28bb4d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322d7265642e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/6d0e63bb9482df87aa6c6ea983969a625be703cd8cfc3460c99eb1e582e6b46f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)

A simple, Laravel-ready tagging package for rapid prototyping and lightweight use cases. Add flexible tagging functionality to any Eloquent model using polymorphic relationships.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#-features)
- [Installation](#-installation)
- [Usage](#-usage)
    - [Making Models Taggable](#1-making-models-taggable)
    - [Making Models Taggers](#2-making-models-taggers)
    - [Working with Tags](#3-working-with-tags)
    - [Working with Tag Groups](#4-working-with-tag-groups)
    - [Attaching Tags to Models](#5-attaching-tags-to-models)
- [Testing](#-testing)
- [Project Structure](#-project-structure)
- [Contributing](#-contributing)
- [License](#-license)

---

🚀 Features
----------

[](#-features)

- Attach tagging functionality to any model using traits
- Polymorphic support for multiple taggable and tagger models
- Tag groups for categorization and organization
- Automatic slug generation for tags and tag groups
- Soft deletes on all entities
- Clean service layer pattern
- UUID support for distributed systems

---

📦 Installation
--------------

[](#-installation)

Install the package with Composer:

```
composer require blamodex/laravel-tags
```

Run the migrations:

```
php artisan migrate
```

---

🧩 Usage
-------

[](#-usage)

### 1. Making Models Taggable

[](#1-making-models-taggable)

Add the `Taggable` trait and implement the `TaggableInterface` to models that can be tagged:

```
use Blamodex\Tags\Traits\Taggable;
use Blamodex\Tags\Contracts\TaggableInterface;

class Post extends Model implements TaggableInterface
{
    use Taggable;
}
```

### 2. Making Models Taggers

[](#2-making-models-taggers)

Add the `Tagger` trait and implement the `TaggerInterface` to models that can create and own tags:

```
use Blamodex\Tags\Traits\Tagger;
use Blamodex\Tags\Contracts\TaggerInterface;

class User extends Model implements TaggerInterface
{
    use Tagger;
}
```

### 3. Working with Tags

[](#3-working-with-tags)

#### Create a tag

[](#create-a-tag)

```
$user = User::find(1);
$tag = $user->createTag('Laravel');
```

#### Find a tag

[](#find-a-tag)

```
$tag = $user->findTag('Laravel');
```

#### Find or create a tag

[](#find-or-create-a-tag)

```
$tag = $user->findOrCreateTag('Laravel');
```

#### Check if user has a tag

[](#check-if-user-has-a-tag)

```
if ($user->hasTag('Laravel')) {
    // Tag exists
}
```

#### Get all tags owned by a user

[](#get-all-tags-owned-by-a-user)

```
$tags = $user->ownedTags();
```

#### Delete a tag

[](#delete-a-tag)

```
$user->deleteTag('Laravel');
```

### 4. Working with Tag Groups

[](#4-working-with-tag-groups)

Tag groups allow you to organize tags into categories.

#### Create a tag group

[](#create-a-tag-group)

```
$user = User::find(1);
$group = $user->createTagGroup('Programming Languages');
```

#### Find a tag group

[](#find-a-tag-group)

```
$group = $user->findTagGroupByName('Programming Languages');
// or by slug
$group = $user->findTagGroupBySlug('programming-languages');
```

#### Assign a tag to a group

[](#assign-a-tag-to-a-group)

```
$tag = $user->findTag('Laravel');
$group = $user->findTagGroupByName('Frameworks');
$user->assignTagToGroup($tag, $group);
```

#### Get all tags in a group

[](#get-all-tags-in-a-group)

```
$tags = $user->getTagsByGroup($group);
```

#### Delete a tag group

[](#delete-a-tag-group)

```
$user->deleteTagGroup('Programming Languages');
```

### 5. Attaching Tags to Models

[](#5-attaching-tags-to-models)

Once you have taggable models and tags, you can attach them:

#### Attach a tag to a model

[](#attach-a-tag-to-a-model)

```
$post = Post::find(1);
$tag = Tag::findByName('Laravel');
$post->attachTag($tag);
```

#### Check if a model has a tag

[](#check-if-a-model-has-a-tag)

```
if ($post->hasTag($tag)) {
    // Post is tagged
}
```

#### Get all tags on a model

[](#get-all-tags-on-a-model)

```
$tags = $post->tags();
```

#### Detach a tag from a model

[](#detach-a-tag-from-a-model)

```
$post->detachTag($tag);
```

#### Detach all tags from a model

[](#detach-all-tags-from-a-model)

```
$post->detachAllTags();
```

#### Sync tags (detach all existing and attach new ones)

[](#sync-tags-detach-all-existing-and-attach-new-ones)

```
$tags = [
    Tag::findByName('Laravel'),
    Tag::findByName('PHP'),
];
$post->syncTags($tags);
```

---

🧪 Testing
---------

[](#-testing)

This package uses [Orchestra Testbench](https://github.com/orchestral/testbench) and [PHPUnit](https://phpunit.de/).

Run tests:

```
composer test
```

Check code style:

```
composer lint
```

Check code style and fix:

```
composer lint:fix
```

Run static analysis:

```
composer analyze
```

Check coverage (with Xdebug):

```
composer test:coverage
```

---

📁 Project Structure
-------------------

[](#-project-structure)

```
src/
├── Models/
│   ├── Tag.php
│   ├── TagGroup.php
│   └── TaggablePivot.php
├── Services/
│   ├── TaggerService.php
│   └── TaggableService.php
├── Traits/
│   ├── Taggable.php
│   ├── Tagger.php
│   └── Sluggable.php
├── Contracts/
│   ├── TaggableInterface.php
│   ├── TaggerInterface.php
│   └── SluggableInterface.php
├── Events/
│   ├── TagCreated.php
│   ├── TagUpdated.php
│   ├── TagDeleted.php
│   ├── TaggablePivotCreated.php
│   └── TaggablePivotDeleted.php
├── Validators/
│   └── TagValidator.php
└── database/
    └── migrations/
        ├── create_tag_groups_table.php
        ├── create_tags_table.php
        └── create_taggable_pivots_table.php

tests/
├── Unit/
├── Fixtures/
└── TestCase.php

```

---

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

---

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for recent changes.

---

📄 License
---------

[](#-license)

MIT © [Blamodex](https://github.com/blamodex)

For more information, see the [LICENSE](LICENSE) file.

---

🔗 Links
-------

[](#-links)

- [Report a Bug](https://github.com/blamodex/laravel-tags/issues)
- [Request a Feature](https://github.com/blamodex/laravel-tags/issues)
- [View Changelog](CHANGELOG.md)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

153d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f55d38385fa6cea42e03e9f4d95bbb789c6c0492de1e386b60e5f2836c96d5d?d=identicon)[blamodex](/maintainers/blamodex)

---

Top Contributors

[![blackmage-codex](https://avatars.githubusercontent.com/u/218423009?v=4)](https://github.com/blackmage-codex "blackmage-codex (62 commits)")

---

Tags

laraveleloquenttagstaggingtaxonomylabelscategorization

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/blamodex-laravel-tags/health.svg)

```
[![Health](https://phpackages.com/badges/blamodex-laravel-tags/health.svg)](https://phpackages.com/packages/blamodex-laravel-tags)
```

###  Alternatives

[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[rtconner/laravel-tagging

Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable.

8833.1M14](/packages/rtconner-laravel-tagging)

PHPackages © 2026

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