Be aware that using pagination will move the contents to ->values()
$products = Product::get()->paginate(12);
return view('frontend/pages/shop')->withProducts($products);
@foreach(array_chunk($products->values(),6) as $product)
Is that possible to use paginate with chunk i mean the bottom number nav with chunk ?
for example i need 6 item per row with chunk and have total 12 item in page with pagination is that something i can do with laravel for now i can use this below code but not success.
In my controller
public function getShop() {
$products = Product::get()->all();
return view('frontend/pages/shop')->withProducts($products);
}
in my view
@foreach(array_chunk($products,6) as $product)
<div class="row mb-4">
@foreach($product as $item)
<div class="col-md-2">
<div class="moveicon-animated-icon" data-icon="{{ asset( 'jsonicons/' . $item->product_jsonicon) }}"></div>
</div>
@endforeach
</div>
@endforeach
how ever the chunk works fine but who i add the pagination with chunk i am aware the paginate function but it did not work for me
thanks in advance
Sorry. I of course meant just ->paginate not ->get()->paginate();
Anyways try
@foreach($products->values()->chunk(6) as $product)
Please or to participate in this conversation.