PHPackages                             sourcedopen/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sourcedopen/laravel-tags

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sourcedopen/laravel-tags
========================

A laravel package for tags

v1.2.0(2mo ago)00MITPHPPHP ^8.1

Since Jan 6Pushed 2mo agoCompare

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

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

Tags
====

[](#tags)

A Laravel package for adding tags to Eloquent models using polymorphic relationships.

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

[](#installation)

You can install the package via Composer:

```
composer require sourcedopen/laravel-tags
```

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

Publish and run the migrations:

```
php artisan vendor:publish --tag="tags-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

### Adding Tags to a Model

[](#adding-tags-to-a-model)

Use the `HasTags` trait in any model you want to be taggable:

```
use Illuminate\Database\Eloquent\Model;
use SourcedOpen\Tags\Traits\HasTags;

class Post extends Model
{
    use HasTags;
}
```

### Creating Tags

[](#creating-tags)

```
use SourcedOpen\Tags\Models\Tag;

$tag = Tag::create([
    'name' => 'Laravel',
    'color' => '#FF2D20', // Optional hex color code
]);
```

### Attaching Tags

[](#attaching-tags)

```
// Attach a single tag
$post->attachTags($tag->id);

// Attach multiple tags
$post->attachTags([$tag1->id, $tag2->id]);
```

### Detaching Tags

[](#detaching-tags)

```
// Detach a single tag
$post->detachTags($tag->id);

// Detach multiple tags
$post->detachTags([$tag1->id, $tag2->id]);
```

### Syncing Tags

[](#syncing-tags)

```
// Sync tags (removes all existing and attaches the provided ones)
$post->syncTags([$tag1->id, $tag2->id]);
```

### Retrieving Tags

[](#retrieving-tags)

```
// Get all tags for a model
$tags = $post->tags;

// Query with tags
$posts = Post::whereHas('tags', function ($query) {
    $query->where('name', 'Laravel');
})->get();
```

Testing
-------

[](#testing)

```
composer test
```

Or run Pest directly:

```
./vendor/bin/pest
```

Code Style
----------

[](#code-style)

This package uses Laravel Pint for code styling:

```
./vendor/bin/pint
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance85

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Every ~35 days

Total

3

Last Release

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51654c14a4ee2015b6fdc0006da24c048533f68081ed29647685640591da3f8c?d=identicon)[chinmay](/maintainers/chinmay)

---

Top Contributors

[![chinmaypurav](https://avatars.githubusercontent.com/u/70144052?v=4)](https://github.com/chinmaypurav "chinmaypurav (8 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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