本文整理汇总了PHP中Quiz::whereRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Quiz::whereRaw方法的具体用法?PHP Quiz::whereRaw怎么用?PHP Quiz::whereRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quiz
的用法示例。
在下文中一共展示了Quiz::whereRaw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
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');
}