Add pagination to shops
This commit is contained in:
parent
c6b7d96a9a
commit
4f87580a78
|
|
@ -7,6 +7,7 @@ is_hidden = 0
|
||||||
function onStart(){
|
function onStart(){
|
||||||
$id = $this->param('id');
|
$id = $this->param('id');
|
||||||
$this['category'] = Tps\Shops\Models\Category::where("id", $id)->get()->first();
|
$this['category'] = Tps\Shops\Models\Category::where("id", $id)->get()->first();
|
||||||
|
$this['shops'] = Tps\Shops\Models\Shop::where('category_id', $this->param('id'))->paginate(12);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
==
|
==
|
||||||
|
|
@ -44,31 +45,12 @@ function onStart(){
|
||||||
<div class="rest_wrap">
|
<div class="rest_wrap">
|
||||||
<div class="rest_box">
|
<div class="rest_box">
|
||||||
<div class="rest_block tabItem active" id="rest-all">
|
<div class="rest_block tabItem active" id="rest-all">
|
||||||
{% for shop in category.shops%}
|
|
||||||
{% partial 'home/shop_item' shop=shop %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section class="rest page">
|
|
||||||
<div class="auto_container">
|
|
||||||
<div class="rest_wrap">
|
|
||||||
<div class="rest_box">
|
|
||||||
<div class="rest_block tabItem active" id="rest-all">
|
|
||||||
{% if id != 0%}
|
|
||||||
{% for category in top_category.categories %}
|
|
||||||
{% for shop in category.shops%}
|
|
||||||
{% partial 'home/shop_item' shop=shop %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
{% for shop in shops%}
|
{% for shop in shops%}
|
||||||
{% partial 'home/shop_item' shop=shop %}
|
{% partial 'home/shop_item' shop=shop %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% partial 'home/pagination' result=shops %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,14 @@ function onStart(){
|
||||||
|
|
||||||
if($this['id'] != 0){
|
if($this['id'] != 0){
|
||||||
$this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->get()->first();
|
$this['top_category'] = Tps\Shops\Models\TopCategory::where("id", $this['id'])->get()->first();
|
||||||
|
$categories = $this['top_category']->categories->pluck('id')->toArray();
|
||||||
|
|
||||||
|
$this['shops'] = Tps\Shops\Models\Shop::whereIn('category_id', $categories)->paginate(12);
|
||||||
}else{
|
}else{
|
||||||
$this['shops'] = Tps\Shops\Models\Shop::orderBy('created_at')->get();
|
$this['shops'] = Tps\Shops\Models\Shop::orderBy('created_at')->paginate(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
==
|
==
|
||||||
<section class="crumb">
|
<section class="crumb">
|
||||||
|
|
@ -51,18 +54,11 @@ function onStart(){
|
||||||
<div class="rest_wrap">
|
<div class="rest_wrap">
|
||||||
<div class="rest_box">
|
<div class="rest_box">
|
||||||
<div class="rest_block tabItem active" id="rest-all">
|
<div class="rest_block tabItem active" id="rest-all">
|
||||||
{% if id != 0%}
|
|
||||||
{% for category in top_category.categories %}
|
|
||||||
{% for shop in category.shops%}
|
|
||||||
{% partial 'home/shop_item' shop=shop %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
{% for shop in shops%}
|
{% for shop in shops%}
|
||||||
{% partial 'home/shop_item' shop=shop %}
|
{% partial 'home/shop_item' shop=shop %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% partial 'home/pagination' result=shops %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
{% if result.hasPages %}
|
||||||
|
|
||||||
|
<div class="pag">
|
||||||
|
<div class="pag_group">
|
||||||
|
{% if result.currentPage > 1 %}
|
||||||
|
<a href="{{ result.previousPageUrl }}" class="pag_btn prev">
|
||||||
|
<svg width="50" height="50" viewBox="0 0 50 50" fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect x="50" y="50" width="50" height="50" rx="10" transform="rotate(-180 50 50)"
|
||||||
|
fill="#FFB100" />
|
||||||
|
<g clip-path="url(#clip0_551_3784)">
|
||||||
|
<path
|
||||||
|
d="M22.0212 25.0001C22.0211 24.9041 22.04 24.809 22.0767 24.7203C22.1134 24.6316 22.1673 24.551 22.2352 24.4831L26.7292 19.9881C26.8666 19.8507 27.0529 19.7736 27.2472 19.7736C27.4415 19.7736 27.6278 19.8507 27.7652 19.9881C27.9026 20.1255 27.9798 20.3118 27.9798 20.5061C27.9798 20.7004 27.9026 20.8867 27.7652 21.0241L23.7882 25.0001L27.7652 28.9741C27.8334 29.0421 27.8874 29.1229 27.9244 29.2119C27.9613 29.3008 27.9804 29.3961 27.9805 29.4924C27.9806 29.5887 27.9617 29.6841 27.9249 29.7731C27.8882 29.8621 27.8342 29.943 27.7662 30.0111C27.6982 30.0793 27.6174 30.1334 27.5285 30.1703C27.4395 30.2072 27.3442 30.2263 27.2479 30.2264C27.1516 30.2265 27.0562 30.2076 26.9672 30.1708C26.8782 30.1341 26.7974 30.0801 26.7292 30.0121L22.2352 25.5171C22.1673 25.4493 22.1134 25.3687 22.0767 25.2799C22.04 25.1912 22.0211 25.0961 22.0212 25.0001Z"
|
||||||
|
fill="#292929" />
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_551_3784">
|
||||||
|
<rect width="10.452" height="5.958" fill="white"
|
||||||
|
transform="translate(27.9785 19.774) rotate(90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<div class="pag_btn prev">
|
||||||
|
<svg width="50" height="50" viewBox="0 0 50 50" fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect x="50" y="50" width="50" height="50" rx="10" transform="rotate(-180 50 50)"
|
||||||
|
fill="#FFB100" />
|
||||||
|
<g clip-path="url(#clip0_551_3784)">
|
||||||
|
<path
|
||||||
|
d="M22.0212 25.0001C22.0211 24.9041 22.04 24.809 22.0767 24.7203C22.1134 24.6316 22.1673 24.551 22.2352 24.4831L26.7292 19.9881C26.8666 19.8507 27.0529 19.7736 27.2472 19.7736C27.4415 19.7736 27.6278 19.8507 27.7652 19.9881C27.9026 20.1255 27.9798 20.3118 27.9798 20.5061C27.9798 20.7004 27.9026 20.8867 27.7652 21.0241L23.7882 25.0001L27.7652 28.9741C27.8334 29.0421 27.8874 29.1229 27.9244 29.2119C27.9613 29.3008 27.9804 29.3961 27.9805 29.4924C27.9806 29.5887 27.9617 29.6841 27.9249 29.7731C27.8882 29.8621 27.8342 29.943 27.7662 30.0111C27.6982 30.0793 27.6174 30.1334 27.5285 30.1703C27.4395 30.2072 27.3442 30.2263 27.2479 30.2264C27.1516 30.2265 27.0562 30.2076 26.9672 30.1708C26.8782 30.1341 26.7974 30.0801 26.7292 30.0121L22.2352 25.5171C22.1673 25.4493 22.1134 25.3687 22.0767 25.2799C22.04 25.1912 22.0211 25.0961 22.0212 25.0001Z"
|
||||||
|
fill="#292929" />
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_551_3784">
|
||||||
|
<rect width="10.452" height="5.958" fill="white"
|
||||||
|
transform="translate(27.9785 19.774) rotate(90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form action="" method="GET">
|
||||||
|
<input type="text" name="page" value="{{result.currentPage}}" class="input_page">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if result.hasMorePages %}
|
||||||
|
<a href="{{ result.nextPageUrl }}" class="pag_btn next">
|
||||||
|
<svg width="50" height="50" viewBox="0 0 50 50" fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="50" height="50" rx="10" fill="#FFB100" />
|
||||||
|
<g clip-path="url(#clip0_551_3788)">
|
||||||
|
<path
|
||||||
|
d="M27.9808 24.9999C27.9808 25.0959 27.962 25.191 27.9253 25.2797C27.8885 25.3684 27.8347 25.449 27.7668 25.5169L23.2728 30.0119C23.1354 30.1493 22.949 30.2264 22.7548 30.2264C22.5605 30.2264 22.3741 30.1493 22.2368 30.0119C22.0994 29.8745 22.0222 29.6882 22.0222 29.4939C22.0222 29.2996 22.0994 29.1133 22.2368 28.9759L26.2138 24.9999L22.2368 21.0259C22.1686 20.9579 22.1145 20.8771 22.0776 20.7881C22.0406 20.6992 22.0216 20.6039 22.0215 20.5076C22.0214 20.4113 22.0403 20.3159 22.077 20.2269C22.1138 20.1379 22.1677 20.057 22.2358 19.9889C22.3038 19.9207 22.3846 19.8666 22.4735 19.8297C22.5624 19.7928 22.6578 19.7737 22.754 19.7736C22.8503 19.7735 22.9457 19.7924 23.0347 19.8292C23.1237 19.8659 23.2046 19.9199 23.2728 19.9879L27.7668 24.4829C27.8347 24.5507 27.8885 24.6313 27.9253 24.7201C27.962 24.8088 27.9808 24.9039 27.9808 24.9999Z"
|
||||||
|
fill="#292929" />
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_551_3788">
|
||||||
|
<rect width="10.452" height="5.958" fill="white"
|
||||||
|
transform="translate(22.0215 30.226) rotate(-90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<div class="pag_btn next">
|
||||||
|
<svg width="50" height="50" viewBox="0 0 50 50" fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="50" height="50" rx="10" fill="#FFB100" />
|
||||||
|
<g clip-path="url(#clip0_551_3788)">
|
||||||
|
<path
|
||||||
|
d="M27.9808 24.9999C27.9808 25.0959 27.962 25.191 27.9253 25.2797C27.8885 25.3684 27.8347 25.449 27.7668 25.5169L23.2728 30.0119C23.1354 30.1493 22.949 30.2264 22.7548 30.2264C22.5605 30.2264 22.3741 30.1493 22.2368 30.0119C22.0994 29.8745 22.0222 29.6882 22.0222 29.4939C22.0222 29.2996 22.0994 29.1133 22.2368 28.9759L26.2138 24.9999L22.2368 21.0259C22.1686 20.9579 22.1145 20.8771 22.0776 20.7881C22.0406 20.6992 22.0216 20.6039 22.0215 20.5076C22.0214 20.4113 22.0403 20.3159 22.077 20.2269C22.1138 20.1379 22.1677 20.057 22.2358 19.9889C22.3038 19.9207 22.3846 19.8666 22.4735 19.8297C22.5624 19.7928 22.6578 19.7737 22.754 19.7736C22.8503 19.7735 22.9457 19.7924 23.0347 19.8292C23.1237 19.8659 23.2046 19.9199 23.2728 19.9879L27.7668 24.4829C27.8347 24.5507 27.8885 24.6313 27.9253 24.7201C27.962 24.8088 27.9808 24.9039 27.9808 24.9999Z"
|
||||||
|
fill="#292929" />
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_551_3788">
|
||||||
|
<rect width="10.452" height="5.958" fill="white"
|
||||||
|
transform="translate(22.0215 30.226) rotate(-90)" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="pag_txt">
|
||||||
|
{{'Всего страниц:'|_}} {{result.lastPage}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
Loading…
Reference in New Issue