本文整理匯總了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'));
}
示例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'));
}
示例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'));
}
示例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;
}
示例5: hasFinishedSurvey
/**
* Determinate if the current member has finished the survey
* @return boolean
*/
private function hasFinishedSurvey()
{
return $this->getCurrentMember()->answer_position == Question::count();
}