hasMany/belongsTo conventions. Supports polymorphic tagging if extended.tagged(), untagged(), and tag() for filtering, but lacks advanced query builders (e.g., nested tag hierarchies or weighted tags).tags and taggable tables, which may conflict with existing schemas or require customization (e.g., soft deletes, custom columns).tags table per model).tag()) be handled? The package lacks explicit transaction support.name and slug.actingAs, factories).Article, Product).tags table).composer require rtconner/laravel-tagging.php artisan vendor:publish --provider="Conner\Tagging\Providers\TaggingServiceProvider".php artisan migrate.use Conner\Tagging\Taggable; to target models.taggable.php):
'taggable' => [
'tagModel' => Conner\Tagging\Tag::class,
'taggableModel' => Conner\Tagging\Taggable::class,
'sluggable' => true,
],
Tag or Taggable classes. Mitigate by aliasing or namespacing.BlogPost) to validate integration.Product, Article).getTagAttribute()) for model-specific logic. Example:
class Article extends Model {
use Taggable;
public function getTagAttribute($value) {
return Str::upper($value); // Custom formatting
}
}
dd(), tap()) and package logs. Example:
\Conner\Tagging\Tag::addGlobalScopes();
taggable_id and tag_id.Cache::remember()).Article::where('published', true)->get()->each->tag('featured');
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Migration conflicts | Downtime if tables exist | Backup database; use --force cautiously. |
| Tag slug collisions | Data loss if "Sugar-Free" vs. "sugar-free" | Pre-migrate data cleanup or disable slugging. |
| High query latency | Slow tag searches | Add full-text indexes or use Scout. |
| Concurrent tag assignment | Race conditions in tag() |
Use database transactions. |
| Package abandonment | Unmaintained code | Fork or replace with spatie/laravel-tagging. |
Article::first()->tag('laravel')).## Tagging Cheat Sheet
- Add tag: `$article->tag('php')`
- Remove tag: `$article->untag('php')`
- Find tagged articles: `Article::tagged('php')`
- Get all tags: `$article->tags`
How can I help you explore Laravel packages today?