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