Ejemplo n.º 1
0
 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'));
 }
 /**
  * Generate unique promo code
  * @return string
  */
 private function getPromoCode()
 {
     $promo_code = getPromoCode();
     $ambassador = Ambassador::wherePromoCode($promo_code)->first();
     if ($ambassador) {
         $this->getPromoCode();
     }
     return $promo_code;
 }