Feature | laravel-tagging | laravel-tags |
---|---|---|
Installation | Requires composer require rtconner/laravel-tagging | Requires composer require spatie/laravel-tags |
Namespace | Conner\Tagging | Spatie\Tags |
Trait for Models | Taggable | HasTags |
Adding Tags | $model->tag('tag1, tag2, tag3'); | $model->attachTags(['tag1', 'tag2']); |
Retrieving Models by Tag | $models = YourModel::withAnyTag(['tag1', 'tag2'])->get(); | $models = YourModel::withAllTags(['tag1', 'tag2'])->get(); |
Removing Tags | $model->untag('tag1'); | $model->detachTags(['tag1']); |
Getting Tags for a Model | $tags = $model->tags; | $tags = $model->tags; |
Tag Counts | $tagCounts = YourModel::existingTags()->get(); | $tagCounts = YourModel::getTags()->pluck('name', 'count'); |
Custom Tag Models | Not supported | $model->attachTags(['tag1', 'tag2'], ['type' => 'custom']); |
Sorting Tags by Count | Not directly supported | $tags = YourModel::tagsWithType('type')->get()->sortByDesc('count'); |
Customizing Tagging Configuration | config/tagging.php | Configuration in config/tags.php |
Soft Deletes Support | Not directly supported | Supports soft deletes through SoftDeletes trait |
Custom Tagging Model | Not directly supported | Supports custom tagging model |
Laravel Version Compatibility | Supports Laravel 5.x, 6.x | Supports Laravel 7.x, 8.x |
Package Documentation | Limited documentation available | Extensive documentation available |
In conclusion, the choice between laravel-tagging
and laravel-tags
depends on your specific project requirements and preferences. Each package has its strengths, so carefully consider the features that matter most to you. Always refer to the official documentation for the most up-to-date information.