/** * Bootstrap any application services. * * @return void */ public function boot(Guard $auth) { view()->composer('*', function ($view) { $pages = Page::orderBy('position', 'asc')->get(); $view->with('pages', $pages); }); view()->composer('*', function ($view) { $view->with('currentUser', Auth::user()); }); view()->composer('sidebar.special', function ($view) { $specialProduct = Product::where('special', 1)->get(); $view->with('specialProduct', $specialProduct); }); view()->composer('sidebar.admin', function ($view) { $today = \Carbon\Carbon::today(); $orders = DB::table('orders')->where('dateOrdered', '=', $today)->where('status_id', '>', 1)->count('id'); $view->with('orders', $orders); }); view()->composer('sidebar.admin', function ($view) { $today = date('l'); $hours = DB::table('hours')->where('day', $today)->value('hours'); $view->with('hours', $hours); }); view()->composer('sidebar.admin', function ($view) { $batches = Batch::where('proddate', \Carbon\Carbon::today())->count(); $view->with('batches', $batches); }); view()->composer('sidebar.admin', function ($view) { $date = date('Y-m-d'); $shift = Shift::where('date', $date)->pluck('id'); $employeees = Shift::find($shift)->users()->count(); $view->with('employeees', $employeees); }); view()->composer('sidebar.special', function ($view) { $categories = Category::all(); $view->with('categories', $categories); }); view()->composer('*', function ($view) use($auth) { $user = Auth::user(); if (Auth::user()) { $cart = DB::table('orders')->select('id')->where('status_id', '=', 1)->where('user_id', '=', $user->id)->value('id'); $cartItems = DB::table('order_products')->where('order_id', '=', $cart)->sum('quantity'); $view->with('cartItems', $cartItems); } }); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $users = User::where('role_id', '<', '3')->get(); $shift = Shift::find($id); return view('shifts.edit', ['users' => $users, 'shift' => $shift]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // return response('Successfully deleted', 200, []); $shift = Shift::find($id); if ($shift) { $shift->delete(); return response('Successfully deleted', 200, []); } else { return response('Something went wrong!', 500, []); } }
public function remove_shift_regis(Request $request) { $shift_id = $request->shift_id; $shift = Shift::find($shift_id); $shift->user_id = 0; $shift->save(); $shift_pick = new ShiftPick(); $shift_pick->user_id = $this->user->id; $shift_pick->shift_id = $shift->id; $shift_pick->status = 0; $shift_pick->save(); $data = json_encode(["id" => $shift->id]); $publish_data = array("event" => "remove-shift", "data" => $data); Redis::publish('colorme-channel', json_encode($publish_data)); return response()->json(['message' => "Bỏ đăng ký thành công", 'status' => 1]); }