/** * List user meals.. * * @return Response */ public function getList() { $dateTime = new \DateTime(); $lastWeekDate = $dateTime->sub(new \DateInterval('P3D')); $meals = Meal::where('user_id', Auth::user()->id)->where('datetime', '>=', $lastWeekDate)->orderBy('datetime', 'DESC')->get(); return view('meal/list', ['meals' => $meals]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $request = request(); $name = $request->has('name') ? $request->get('name') : ''; $mealTime = $request->has('meal_time') ? $request->get('meal_time') : ''; $meals = Meal::where(function ($query) use($name, $mealTime) { if (!empty($name)) { $query->where('name', 'LIKE', "%{$name}%"); } if (!empty($mealTime)) { $query->where('meal_time', $mealTime); } })->orderBy('sort_order', 'ASC')->paginate(env('LIMIT', 15)); return view('meals.index', compact('meals', 'name', 'mealTime')); }
public function dashboard() { /** * Log the user out if not admin */ if (auth()->user()->is_admin == 0) { auth()->logout(); return redirect()->to('/login')->withErrors(['email' => 'Only admin is allowed']); } $appUsers = User::count(); $ambassadors = Ambassador::count(); $subscribedUsers = UserSubscription::GroupBy('user_id')->count(); $news = Feed::where('is_deleted', 0)->where('type', 1)->count(); $videos = \DB::table('videos')->join('video_categories', 'video_categories.id', '=', 'videos.video_category_id')->where('videos.is_deleted', 0)->where('video_categories.type', 1)->count(); $scholarships = Feed::where('is_deleted', 0)->where('type', 2)->count(); $sat_act = Feed::where('is_deleted', 0)->where('type', 3)->count(); //$coachesCorner = Feed::where('is_deleted', 0)->where('type', 4)->count(); $meals = Meal::where('is_deleted', 0)->count(); $weightTraining = \DB::table('videos')->join('video_categories', 'video_categories.id', '=', 'videos.video_category_id')->where('videos.is_deleted', 0)->where('video_categories.type', 2)->count(); $schedules = WorkoutSchedule::where('is_deleted', 0)->count(); $items = Item::where('is_deleted', 0)->count(); return view('dashboard', compact('appUsers', 'ambassadors', 'subscribedUsers', 'news', 'videos', 'scholarships', 'sat_act', 'meals', 'weightTraining', 'schedules', 'items')); }
public function btnClickDinner($id) { $client = Client::findOrFail($id); $meal = Meal::where('date_fed', '=', date('Y-m-d'))->where('client_id', '=', $client->id)->first(); if ($meal->dinner == 1) { \DB::table('meals')->where('client_id', '=', $client->id)->where('date_fed', '=', date('Y-m-d'))->update(['dinner' => 0, 'client_id' => $client->id]); } else { \DB::table('meals')->where('client_id', '=', $client->id)->where('date_fed', '=', date('Y-m-d'))->update(['dinner' => 1, 'client_id' => $client->id]); } return redirect(action('MealController@mealRosterDinner')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(Request $request, $id) { $foods = Food::all(); $meal = Meal::where('id', $id)->first(); if ($meal && ($request->user()->id == $meal->user_id || $request->user()->is_admin())) { return view('meals.edit')->with('meal', $meal)->withFoods($foods); } return redirect('/meal/index')->withErrors('You do not have sufficient permissions'); }