コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     if ($request->has('search')) {
         $products = Product::where('is_active', 1)->where('id', 'LIKE', "%" . $request->input('search') . "%")->orWhere('product_name', 'LIKE', "%" . $request->input('search') . "%")->paginate(5);
     } else {
         if ($request->has('sortby')) {
             $products = Product::orderBy($request->input('sortby'))->paginate(5);
         } else {
             $products = Product::paginate(5);
         }
     }
     $products->setPath(url() . '/back/product');
     return view('pages.admin.product.list', ['products' => $products]);
 }