У меня проблема с нумерацией страниц. при использовании его с фильтром работает только первая страница.
Контроллер
public function create(Request $request)
{
$products = Product::where(function($query) {
// filter category
$category = Input::has('category')
? Input::get('category')
: ['Clothes','Pants','Equipments','Shoes','Gears'];
if (isset($category)) {
$query->whereIn('category',$category);
}
// filter price
$min_price = Input::has('min_price') ? Input::get('min_price') : 1 ;
$max_price = Input::has('max_price') ? Input::get('max_price') : 999 ;
if (isset($min_price) && isset($max_price)) {
$query->where('price','>=',$min_price)
->where('price','<=',$max_price);
}
// filter brand
$brand = Input::has('brand')
? Input::get('brand')
: ['Adidas','Nike','Puma','Mizuno','Umbro','Line 7'];
if (isset($brand)) {
$query->whereIn('brand',$brand);
}
// filter store
$store = Input::has('store')
? Input::get('store')
: ['JD Sports Malaysia','SportsClick','Al-Ikhsan','Sports Wear','Sports Direct'];
if (isset($store)) {
$query->whereIn('store',$store);
}
//filter Gender
$gender = Input::has('gender')
? Input::get('gender')
: ['Male','Female','None'];
if(isset($gender)){
$query->whereIn('gender',$gender);
}
$search = Input::get('query');
if (isset($search)) {
$query->where('product','like',"%$search%")
->orWhere('brand', 'like', "%$search%")
->orWhere('category', 'like', "%$search%")->get();
}
})->paginate(12);
return view('customer.category',compact('products'))->withProduct($products);
}
лезвие
<!-- store bottom filter -->
<div class="store-filter clearfix mt-5">
<span class="store-qty">Showing {{$products->count()}} Result(s)</span>
<ul class="store-pagination"
{!! $products->links();!!}
</ul>
</div>
<!-- /store bottom filter -->
Код контроллера - это то, как я получаю вход фильтра
и представление о том, как отображать пагинационную ссылку
страница с номером 2 и выше должна отображать отфильтрованный продукт