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


PHP Question::count方法代码示例

本文整理汇总了PHP中app\Question::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::count方法的具体用法?PHP Question::count怎么用?PHP Question::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Question的用法示例。


在下文中一共展示了Question::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (!Auth::check()) {
         return redirect('home')->with('message', "Veuillez d'abord vous connecter");
     }
     $question = Question::find($id);
     if (is_null($question)) {
         abort(404);
     }
     $total_questions = Question::count();
     $user = Auth::user();
     $total_questions_replied = $user->questionsReplied()->count();
     $total_questions_replied_percent = round($total_questions_replied / $total_questions * 100);
     // Get the current user that will be the origin of our operations
     // Get ID of a User whose autoincremented ID is less than the current user, but because some entries might have been deleted we need to get the max available ID of all entries whose ID is less than current user's
     $previousQuestionID = Question::where('id', '<', $question->id)->max('id');
     // Same for the next user's id as previous user's but in the other direction
     $nextQuestionID = Question::where('id', '>', $question->id)->min('id');
     $replies = $question->getChoices();
     // if user already replied to this particular question
     if ($question->getAnswer()) {
         $replies[$question->getAnswer()]['checked'] = true;
         $question->replied = true;
     }
     return view('questions.show', compact('question', 'previousQuestionID', 'nextQuestionID', 'replies', 'total_questions', 'total_questions_replied', 'total_questions_replied_percent'));
 }
开发者ID:philippejadin,项目名称:mooc,代码行数:32,代码来源:QuestionsController.php

示例2: index

 public function index()
 {
     $title = "Dashboard";
     $questions = Question::count();
     $questioncategories = QuestionCategory::count();
     $users = User::count();
     return view('admin.dashboard.index', compact('title', 'questions', 'questioncategories', 'countries', 'users'));
 }
开发者ID:alex311982,项目名称:laravel5_online_support,代码行数:8,代码来源:DashboardController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts_published = Post::published()->count();
     $posts_editing = Post::where('published', 'uc')->count();
     $posts_sticky = Post::where('is_sticky', 'on')->count();
     $posts = Post::count();
     $users = User::count();
     $jobs = Job::count();
     $questions = Question::count();
     $categories = Category::count();
     return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
 }
开发者ID:celine24,项目名称:Back,代码行数:17,代码来源:StatsController.php

示例4: all

 /**
  * return the questions from the database
  * 
  * @return array       questions
  */
 public function all(Request $request)
 {
     if (!Auth::check()) {
         return Response::json(['error' => ['message' => 'not authorized, not logged in']]);
     } else {
         if (!Auth::user()->isAdmin()) {
             return Response::json(['error' => ['message' => 'not authorized, elevated permissions needed']]);
         }
     }
     $questionsCount = Question::count();
     // get the questions for that page
     $questions = Question::orderby('sequence')->get();
     // add the number of answers for each question
     for ($i = 0; $i < $questionsCount; $i++) {
         $questions[$i]['answersCount'] = $questions[$i]->answersCount();
     }
     $result = array('questions' => $questions, 'questionsCount' => $questionsCount);
     // return the result
     return $result;
 }
开发者ID:jvanraemdonck,项目名称:Websitespel,代码行数:25,代码来源:QuestionController.php

示例5: hasFinishedSurvey

 /**
  * Determinate if the current member has finished the survey
  * @return boolean
  */
 private function hasFinishedSurvey()
 {
     return $this->getCurrentMember()->answer_position == Question::count();
 }
开发者ID:Sparclex,项目名称:studie,代码行数:8,代码来源:SurveyController.php


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