Group by name only

Fixes #63
Fixes #64
This commit is contained in:
Christopher C. Wells 2024-02-02 10:22:46 -08:00
parent 2a05ebc3c8
commit b955eb53b8
1 changed files with 2 additions and 2 deletions

View File

@ -52,9 +52,9 @@ trait Ingredient
public static function getTagTotals(string $locale = null): DatabaseCollection { public static function getTagTotals(string $locale = null): DatabaseCollection {
$locale = $locale ?? app()->getLocale(); $locale = $locale ?? app()->getLocale();
return Tag::query()->join('taggables', 'taggables.tag_id', '=', 'id') return Tag::query()->join('taggables', 'taggables.tag_id', '=', 'id')
->select(['id', 'name', DB::raw('count(*) as total')]) ->select(['name', DB::raw('count(*) as total')])
->where('taggables.taggable_type', '=', static::class) ->where('taggables.taggable_type', '=', static::class)
->groupBy('id') ->groupBy('name')
->orderBy("name->{$locale}") ->orderBy("name->{$locale}")
->get(); ->get();
} }