/** * @POST("/filtered/{shops}", middleware="auth", as="shops.filtered") * @internal param Request $request * @param Shops $shops * @return \Illuminate\View\View */ public function filterItems(Shops $shops) { if (\Request::input('cat_id') == 0) { $items = ShopItems::with('shop')->where('shop_id', '=', $shops->id)->paginate(20); } else { $items = ShopItems::with('shop')->where('shop_id', '=', $shops->id)->where('category_id', \Request::input('cat_id'))->paginate(20); } $shop_id = Shops::where('id', $shops->id)->first()->id; $categories = \DB::select("select cat.name, cat.id\n from categories_shops d\n join shops m on d.shop_id = m.id\n \t\t join items_category cat on d.category_id = cat.id\n \t\t where m.id = {$shop_id}"); return view('shops::show', compact('shops', 'items', 'categories')); }
/** * Show the form for editing the specified resource. * @Get("/shopitems/{id}/edit", as="shopitems.edit") * @Middleware("auth") * @param $id * @return \Illuminate\View\View */ public function edit($id) { $items = ShopItems::with('attachment')->find($id); $shop_id = $items->shop_id; $categories = \DB::select("select cat.name, cat.id\n from categories_shops d\n join shops m on d.shop_id = m.id\n \t\t join items_category cat on d.category_id = cat.id\n \t\t where m.id = {$shop_id}"); return view('shops::shopitems.edit', compact('items', 'shop_id', 'categories')); }