本文整理汇总了PHP中app\Question::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::select方法的具体用法?PHP Question::select怎么用?PHP Question::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid(Request $request)
{
$questionId = $request['questionId'];
$answerId = $request['answerId'];
$correctQuestionDB = Question::select('correct_answer_id')->findOrFail($questionId);
if ($answerId == $correctQuestionDB->correct_answer_id) {
$user = \Auth::user();
$user->correct_answers++;
$user->save();
return 1;
} else {
return 0;
}
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$questions = Question::select('question', 'answer0', 'answer1', 'answer2', 'answer3', 'correct_answer', 'answer0_image', 'answer1_image', 'answer2_image', 'answer3_image')->get();
$q = null;
for ($j = 0; $j < count($questions); $j++) {
$answers = null;
$images = null;
for ($i = 0; $i < 4; $i++) {
$answers = array_add($answers, $i, ['id' => $i, 'text' => $questions[$j]['answer' . $i], 'image' => $questions[$j]['answer' . $i . '_image']]);
}
$q = array_add($q, $j, ['question' => $questions[$j]->question, 'answers' => $answers, 'correct' => $questions[$j]->correct_answer]);
}
return $q;
}