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')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $schools = $this->schools; $request = request(); $title = $request->has('title') ? $request->get('title') : ''; $schoolId = $request->has('school_id') ? $request->get('school_id') : ''; $from = $request->has('start_date') ? $request->get('start_date') : ''; $to = $request->has('end_date') ? $request->get('end_date') : ''; $schedules = WorkoutSchedule::where(function ($query) use($title, $schoolId, $from, $to) { if (!empty($title)) { $query->where('title', 'LIKE', "%{$title}%"); } if (!empty($schoolId)) { $query->where('school_id', $schoolId); } if (!empty($from)) { $query->where('start_date', '>=', $from); } if (!empty($to)) { $query->where('end_date', '<=', $to); } })->paginate(env('LIMIT', 15)); return view('schedules.index', compact('schedules', 'schools', 'title', 'schoolId', 'from', 'to')); }