当前位置: 首页>>代码示例>>PHP>>正文


PHP Quiz::whereRaw方法代码示例

本文整理汇总了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');
 }
开发者ID:thunderclap560,项目名称:quizkpop,代码行数:29,代码来源:AdminController.php


注:本文中的Quiz::whereRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。