本文整理汇总了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();
}