I have two methods:
public function specific_shop(Request $request)
{
$categories = Category::all();
$products = Product::where('shop_id', $request->id)->orderBy('quantity', 'asc')->paginate(10);
return view('product.show', compact('products', 'categories'));
}
public function specific_category(Request $request)
{
$products = Product::where('category_id', $request->id)->orderBy('quantity', 'asc')->paginate(10);
return view('product.specific', compact('products'));
}
The first one is giving me Products from specific shop (after choosing from select input) and the second one is giving me Products from specific category.
Route::resource('product', 'ProductController');
Route::get('/product/show/shop/specific', 'ProductController@specific_shop');
Route::get('/product/show/category/specific', 'ProductController@specific_category');
Pagination works when I hit /product/ and it shows all products (not specified) but if I hit /product/show/shop/specific (via form) pagination is not working correctly. It seems like it doesn't even work at all. First page is fine but if I click next, it returns nothing. Blank table. I don't know why.