153 lines
6.8 KiB
HTML
153 lines
6.8 KiB
HTML
title = "main-category"
|
||
url = "/main-category/:id"
|
||
layout = "default"
|
||
is_hidden = 0
|
||
==
|
||
<?php
|
||
function onStart()
|
||
{
|
||
|
||
$currentUrl = url()->full();
|
||
$urlComponents = parse_url($currentUrl);
|
||
$queryString = $urlComponents['query'] ?? '';
|
||
parse_str($queryString, $queryParams);
|
||
$floorID = $queryParams['floor'] ?? null;
|
||
|
||
if (!is_null($floorID)) {
|
||
$this['id'] = $this->param('id');
|
||
|
||
if ($this['id'] != 0) {
|
||
$this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->first();
|
||
$categories = $this['top_category']->categories->pluck('id')->toArray();
|
||
|
||
$this['shops'] = Tps\Shops\Models\Shop::whereIn('category_id', $categories)
|
||
->where('floor', $floorID)
|
||
->paginate(12)
|
||
->appends(['floor' => $floorID]);
|
||
} else {
|
||
$this['shops'] = Tps\Shops\Models\Shop::where('floor', $floorID)
|
||
->orderBy('created_at')
|
||
->paginate(12)
|
||
->appends(['floor' => $floorID]);
|
||
}
|
||
} else {
|
||
$this['id'] = $this->param('id');
|
||
|
||
if ($this['id'] != 0) {
|
||
$this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->first();
|
||
$categories = $this['top_category']->categories->pluck('id')->toArray();
|
||
|
||
$this['shops'] = Tps\Shops\Models\Shop::whereIn('category_id', $categories)->paginate(12);
|
||
} else {
|
||
$this['shops'] = Tps\Shops\Models\Shop::orderBy('created_at')->paginate(12);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
function onUpdate()
|
||
{
|
||
|
||
$floorID = post('floorID');
|
||
|
||
$data = Tps\Shops\Models\Shop::orderBy('created_at')
|
||
->where('floor', $floorID)
|
||
->paginate(12)
|
||
->appends(['floor' => $floorID]);
|
||
|
||
return [
|
||
'home/shop_item' => $this->renderPartial('home/shop_item', ['shops' => $data]),
|
||
'home/pagination' => $this->renderPartial('home/pagination', ['result' => $data]) // Update this with the correct data
|
||
];
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
?>
|
||
==
|
||
<section class="crumb">
|
||
<div class="auto_container">
|
||
<div class="crumb_wrap">
|
||
<div class="crumb_row">
|
||
<a href="{{'home'|page}}" class="crumb_title">
|
||
<span>
|
||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
|
||
xmlns="http://www.w3.org/2000/svg">
|
||
<path
|
||
d="M1.25 12.88V6.91459C1.25 6.33752 1.51642 5.79278 1.97193 5.4385L6.85193 1.64294C7.52721 1.11773 8.47279 1.11773 9.14807 1.64294L14.0281 5.4385C14.4836 5.79278 14.75 6.33752 14.75 6.91459V12.88C14.75 13.9128 13.9128 14.75 12.88 14.75H10.75C10.4739 14.75 10.25 14.5261 10.25 14.25V11.6487C10.25 11.3855 10.207 11.1193 10.0677 10.896C9.88545 10.6039 9.64228 10.3523 9.35303 10.1595C8.95253 9.89251 8.48167 9.75 8 9.75C7.51833 9.75 7.04747 9.89251 6.64697 10.1595C6.35772 10.3523 6.11455 10.6039 5.93234 10.896C5.79305 11.1193 5.75 11.3855 5.75 11.6487V14.25C5.75 14.5261 5.52614 14.75 5.25 14.75H3.12C2.08723 14.75 1.25 13.9128 1.25 12.88Z"
|
||
stroke="#292929" stroke-width="1.5" stroke-linecap="round"
|
||
stroke-linejoin="round" />
|
||
</svg>
|
||
</span>
|
||
{{'Главная'|_}}
|
||
</a>
|
||
<h4 class="crumb_title">
|
||
{% if id != 0%}
|
||
{{top_category.name}}
|
||
{% else %}
|
||
{{'Все магазины'|_}}
|
||
{% endif %}
|
||
</h4>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="rest page">
|
||
<div class="auto_container">
|
||
<div class="rest_wrap">
|
||
|
||
|
||
<div class="shops_wrap">
|
||
<div class="shops_sort">
|
||
|
||
<form action="{{ 'search'|page }}" method="GET" class="menu_search">
|
||
<div class="shops_search">
|
||
<input type="text" name="q" placeholder="{{'Поиск магазина'|_}}">
|
||
|
||
<button type="submit">
|
||
<svg width="19" height="19" viewBox="0 0 19 19" fill="none"
|
||
xmlns="http://www.w3.org/2000/svg">
|
||
<path
|
||
d="M17.71 16.29L14.31 12.9C15.407 11.5025 16.0022 9.77666 16 8C16 6.41775 15.5308 4.87103 14.6518 3.55544C13.7727 2.23985 12.5233 1.21447 11.0615 0.608967C9.59966 0.00346625 7.99113 -0.15496 6.43928 0.153721C4.88743 0.462403 3.46197 1.22433 2.34315 2.34315C1.22433 3.46197 0.462403 4.88743 0.153721 6.43928C-0.15496 7.99113 0.00346625 9.59966 0.608967 11.0615C1.21447 12.5233 2.23985 13.7727 3.55544 14.6518C4.87103 15.5308 6.41775 16 8 16C9.77666 16.0022 11.5025 15.407 12.9 14.31L16.29 17.71C16.383 17.8037 16.4936 17.8781 16.6154 17.9289C16.7373 17.9797 16.868 18.0058 17 18.0058C17.132 18.0058 17.2627 17.9797 17.3846 17.9289C17.5064 17.8781 17.617 17.8037 17.71 17.71C17.8037 17.617 17.8781 17.5064 17.9289 17.3846C17.9797 17.2627 18.0058 17.132 18.0058 17C18.0058 16.868 17.9797 16.7373 17.9289 16.6154C17.8781 16.4936 17.8037 16.383 17.71 16.29ZM2 8C2 6.81332 2.3519 5.65328 3.01119 4.66658C3.67047 3.67989 4.60755 2.91085 5.7039 2.45673C6.80026 2.0026 8.00666 1.88378 9.17055 2.11529C10.3344 2.3468 11.4035 2.91825 12.2426 3.75736C13.0818 4.59648 13.6532 5.66558 13.8847 6.82946C14.1162 7.99335 13.9974 9.19975 13.5433 10.2961C13.0892 11.3925 12.3201 12.3295 11.3334 12.9888C10.3467 13.6481 9.18669 14 8 14C6.4087 14 4.88258 13.3679 3.75736 12.2426C2.63214 11.1174 2 9.5913 2 8Z"
|
||
fill="white" />
|
||
</svg>
|
||
</button>
|
||
</div>
|
||
|
||
<div class="custom-select w150" id="mySelect">
|
||
|
||
|
||
<select name="floorSelect" data-request="onChangeValue" onchange="handleChange(this)">
|
||
<option value="">{{'Все этажы'|_}}</option>
|
||
<option value="0">0</option>
|
||
<option value="1">1</option>
|
||
<option value="2">2</option>
|
||
<option value="3">3</option>
|
||
<option value="4">4</option>
|
||
</select>
|
||
|
||
<div id="output"></div>
|
||
|
||
|
||
</div>
|
||
</form>
|
||
|
||
</div>
|
||
|
||
<div class="rest_box">
|
||
<div class="rest_block tabItem active" id="rest-all">
|
||
{% partial 'home/shop_item' shops=shops %}
|
||
</div>
|
||
{% partial 'home/pagination' result=shops %}
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|