PHPackages                             sourcedopen/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/tags

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

sourcedopen/tags
================

A laravel package for tags

v1.2.0(3mo ago)0315MITPHPPHP ^8.1

Since Jan 6Pushed 3mo agoCompare

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

READMEChangelog (3)Dependencies (5)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

39

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

97d 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 (9 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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