Category: Laravel
-
Laravel-Tagging vs Laravel-Tags: A Tagging Package Comparison
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…