Taggable), aligning with Laravel’s Eloquent conventions. This is a clean separation of concerns for applications requiring hierarchical or associative metadata (e.g., CMS, e-commerce, or content platforms).belongsToMany relationship via a taggables pivot table, reducing custom boilerplate. However, this introduces a generic table that may conflict with existing pivot tables if not namespaced carefully.tags and taggables), which must be backward-compatible with existing migrations (e.g., no foreign key conflicts).Post::withTags(['laravel'])), requiring manual pivot table joins or custom scopes.taggables table is generic; risk of conflicts if another package uses the same naming convention.composer require oleaass/laravel-tags
php artisan migrate
use Taggable; to target models (e.g., Post, Product).class Post extends Model {
use \OleAass\Tags\Taggable;
}
Tag::create() or a seeder.POST /posts/{id}/tags).$post->tags()->attach(request('tag_ids'));
taggables table. Mitigate by:
post_tags).SoftDeletes, ensure the pivot table includes deleted_at or handle soft deletes manually.Post) to validate functionality.oleaass/laravel-tags doesn’t pull in unnecessary dependencies.taggables on tag_id and taggable_id.N+1 queries when loading tagged models. Use eager loading:
$posts = Post::with('tags')->get();
tags() relationship) or denormalize tags into JSON columns.DB::transaction(function () {
$post->tags()->attach([$tagId]);
});
taggables tables. Profile with tools like Laravel Debugbar.tags table. Implement validation or moderation.attach/detach methods).whereHas('tags')).How can I help you explore Laravel packages today?