I am new in laravel and i am making a quiz app where there are four possible answers of a question and one is correct .The questions and answers are stored in database, my code works only on one question.
this is my code in controller
$answers =$request->all();
$getAnswer=Question::where('ans',[$request->ans])->get();
if ($getAnswer->isEmpty()) {
return back()->withErrors(['fail' => ['Wrong Answer']]);
}
else {
return redirect()->back()->with('success', 'your Answer is Correct');
}```
Can anybody please help me...
Aucun commentaire:
Enregistrer un commentaire