/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $cat_id = \DB::table('items_category')->insertGetId(array('name' => $request->input('name'), 'description' => $request->input('description'))); \DB::table('categories_shops')->insert(array('shop_id' => $request->input('shop_id'), 'category_id' => $cat_id)); $shops = Shops::where('user_id', \Auth::user()->id)->orderBy('id', 'desc')->paginate(5); return view('shops::index', compact('shops')); }
/** * @param Shops $shop * @return \Illuminate\View\View */ public function edit(Shops $shop) { $shop = Shops::where('id', $shop->id)->first(); return view('admin.shops.edit', compact('shop')); }
/** * @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')); }
/** * @param Request $request * @return \Illuminate\View\View */ public function filter(Request $request) { $shops = Shops::where('category_id', $request->input('id'))->where('blocked', 0)->where('paid_at', '>=', new \DateTime('today'))->orderBy('id', 'desc')->paginate(5); return view('shops::index', compact('shops'))->with('category', $request->input('id')); }