cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
559 stars 72 forks source link

Get where tags count more than 2 #52

Closed Katerou22 closed 7 years ago

Katerou22 commented 7 years ago

Is it possible to get tags which used twice or three times? something like this:

Tags::where('count', '>', '3')->get();

cviebrock commented 7 years ago

This is supported in the 3.0.1 release:

For one model's tags:

// Return the top 10 most popular tags, as long as each tag has been used at least 3 times
$tags = $model->popularTags(10, 3);

If you share tags across models, it's a bit more code:

// Return the top 10 most popular tags, across all models, with a count of at least 3
$tagService = app(\Cviebrock\EloquentTaggable\Services\TagService::class);
$tagService->getPopularTags($limit, null, $minimumCount);