diff --git a/app/Repositories/Shop/TagGroups.php b/app/Repositories/Shop/TagGroups.php index 316bffda..8f3804c2 100644 --- a/app/Repositories/Shop/TagGroups.php +++ b/app/Repositories/Shop/TagGroups.php @@ -16,15 +16,19 @@ class TagGroups public static function getWithTagsAndCountOffers($category_id = false) { - $tags = Tag::withCount(['articles'])->get()->toArray(); + $tags = Tag::withCount(['articles' => function($query) use ($category_id) { + $query->byCategory($category_id); + }])->get()->toArray(); $tag_groups = TagGroup::pluck('name', 'id')->toArray(); foreach ($tags as $tag) { $data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']]; - $data[$tag['tag_group_id']]['tags'][] = [ - 'id' => $tag['id'], - 'name' => $tag['name'], - 'count' => $tag['articles_count'], - ]; + if ($tag['articles_count']) { + $data[$tag['tag_group_id']]['tags'][] = [ + 'id' => $tag['id'], + 'name' => $tag['name'], + 'count' => $tag['articles_count'], + ]; + } } return $data; } diff --git a/resources/views/Shop/Tags/partials/filter.blade.php b/resources/views/Shop/Tags/partials/filter.blade.php index 829db31a..932ea10e 100644 --- a/resources/views/Shop/Tags/partials/filter.blade.php +++ b/resources/views/Shop/Tags/partials/filter.blade.php @@ -8,20 +8,22 @@ @foreach ($tags as $tag_group_id => $group) - @component('components.layout.box-collapse', [ - 'title' => $group['name'], - 'id' => 'tag_group_' . $tag_group_id, - ]) - @foreach ($group['tags'] as $tag) -