modify filter calculation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,20 +8,22 @@
|
||||
</div>
|
||||
|
||||
@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)
|
||||
<div>
|
||||
@include('components.form.checkbox', [
|
||||
'name' => 'tag[]',
|
||||
'val' => $tag['id'],
|
||||
])
|
||||
{{ $tag['name'] }} ({{ $tag['count'] }})
|
||||
</div>
|
||||
@endforeach
|
||||
@endcomponent
|
||||
@if ($group['tags'] ?? false)
|
||||
@component('components.layout.box-collapse', [
|
||||
'title' => $group['name'],
|
||||
'id' => 'tag_group_' . $tag_group_id,
|
||||
])
|
||||
@foreach ($group['tags'] as $tag)
|
||||
<div>
|
||||
@include('components.form.checkbox', [
|
||||
'name' => 'tag[]',
|
||||
'val' => $tag['id'],
|
||||
])
|
||||
{{ $tag['name'] }} ({{ $tag['count'] }})
|
||||
</div>
|
||||
@endforeach
|
||||
@endcomponent
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
</section>
|
||||
@@ -33,7 +35,9 @@
|
||||
<script>
|
||||
$('#filters').click(function() {
|
||||
$('#sidebar').toggleClass('d-none');
|
||||
})
|
||||
$('#filter-on').toggleClass('d-none');
|
||||
$('#filter-off').toggleClass('d-none');
|
||||
});
|
||||
initChevron();
|
||||
</script>
|
||||
@endpush
|
||||
@@ -59,8 +59,6 @@
|
||||
<script>
|
||||
function refreshBasketTop() {
|
||||
$.get("{{ route('Shop.Basket.getSummary') }}", function(response) {
|
||||
console.log("refreshBasketTop()");
|
||||
console.log(response);
|
||||
$('#count-basket').html(response.data.quantity);
|
||||
$('#total-basket').html(response.data.total);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
|
||||
<div class="col-3 form-inline">
|
||||
<a href="/"><img src="/img/logo.jpg" class="img-responvive"></a>
|
||||
<a id="filters" href="#" class="text-white pl-3"><i class="fa fa-2x fa-bars"></i></a>
|
||||
<a id="filters" href="#" class="text-white pl-3">
|
||||
<span id="filter-on" class="fa-stack fa-2x">
|
||||
<i class="fa fa-stack-1x fa-filter"></i>
|
||||
</span>
|
||||
<span id="filter-off" class="fa-stack fa-2x d-none">
|
||||
<i class="fa fa-stack-1x fa-filter"></i>
|
||||
<i class="fa fa-stack-2x fa-ban" style="color:Tomato"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-5 form-inline">
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
<div class="col-12 text-right p-2">
|
||||
<button type="button" class="btn bg-green-dark light" data-toggle="dropdown">
|
||||
<i class="fa fa-2x fa-fw fa-user mr-2"></i>
|
||||
<span id="username" class="ml-2 badge bg-yellow green-dark">
|
||||
{{ App\Repositories\Shop\Customers::getName() }}
|
||||
</span>
|
||||
@if (App\Repositories\Shop\Customers::getName())
|
||||
<span id="username" class="ml-2 badge bg-yellow green-dark">
|
||||
{{ App\Repositories\Shop\Customers::getName() }}
|
||||
</span>
|
||||
@endif
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu" aria-labelledby="dLabel">
|
||||
|
||||
Reference in New Issue
Block a user