本文整理汇总了PHP中app\Question::findOrfail方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::findOrfail方法的具体用法?PHP Question::findOrfail怎么用?PHP Question::findOrfail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::findOrfail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(\Illuminate\Http\Request $request)
{
$points = 0;
$question = Question::findOrfail(Input::get('id'));
$course = $question->test()->first()->course()->first();
$this->change($request);
if ($request->guess1 == 1 && $question->correct1 == 1) {
$points++;
}
if ($request->guess2 == 1 && $question->correct2 == 1) {
$points++;
}
if ($request->guess3 == 1 && $question->correct3 == 1) {
$points++;
}
if ($request->guess4 == 1 && $question->correct4 == 1) {
$points++;
}
if ($request->guess5 == 1 && $question->correct5 == 1) {
$points++;
}
if ($request->guess1 == 1 && $question->correct1 == 0) {
$points--;
}
if ($request->guess2 == 1 && $question->correct2 == 0) {
$points--;
}
if ($request->guess3 == 1 && $question->correct3 == 0) {
$points--;
}
if ($request->guess4 == 1 && $question->correct4 == 0) {
$points--;
}
if ($request->guess5 == 1 && $question->correct5 == 0) {
$points--;
}
$enroll = Enroll::where(['course_id' => $course->id, 'user_id' => Auth::user()->id])->first();
$enroll->points += $points;
if ($enroll->points < 0) {
$enroll->points = 0;
}
$enroll->save();
}