public function index()
 {
     $totalQuizzesCount = Quiz::count();
     $totalUsersCount = User::count();
     $todayQuizzesCount = Quiz::whereRaw('DATE(created_at) = DATE(NOW())')->count();
     $todayUsersCount = User::whereRaw('DATE(created_at) = DATE(NOW())')->count();
     $overallActivities = QuizUserActivity::groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
     $overallStats = array();
     foreach ($overallActivities as $activity) {
         $overallStats[$activity['type']] = $activity['count'];
     }
     $overallStats['quizzes'] = $totalQuizzesCount;
     $overallStats['users'] = $totalUsersCount;
     $todayActivities = QuizUserActivity::whereRaw('DATE(created_at) = DATE(\'' . date('Y-m-d H:i:s') . '\')')->groupBy('type')->havingRaw("type in ('attempt', 'share')")->select('type', DB::raw('count(*) as count'))->get()->toArray();
     $todayStats = array();
     foreach ($todayActivities as $activity) {
         $todayStats[$activity['type']] = $activity['count'];
     }
     $todayStats['quizzes'] = $todayQuizzesCount;
     $todayStats['users'] = $todayUsersCount;
     //Filling stats vars that are not yet set
     self::fillNullStats($todayStats);
     self::fillNullStats($overallStats);
     View::share(array('overallStats' => $overallStats, 'todayStats' => $todayStats));
     $last30DaysActivity = self::getLastNDaysActivity(30, 'attempt');
     $last30DaysUserRegistrations = self::getLastNDaysUserRegistrations(30);
     View::share(array('last30DaysActivity' => json_encode($last30DaysActivity), 'last30DaysUserRegistrations' => json_encode($last30DaysUserRegistrations)));
     return View::make('admin/index');
 }