當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。