I am trying to send values in database through this loop, its basically a quiz system where i am updating data by this query. there are 5 options but i dont know why it is only updating first value even i updated 5th option. is there any problem in code please help me to find out a bug in it.
$chapter_id = $request->chapter_id;
$questions = Question::orderBy('id', 'asc')->paginate(25);
$question = Question::findOrF
for($a=1; $a<=5; $a++){
$option = 'text_option_'. $a ;
// if($option != ''){
$question_option = QuestionsOption::where('question_id', $question->id)->first();
// $question_option -> question_id = $question->id;
$question_option -> question_text = $request -> $option;
$question_option -> correct = $request->input('correct_' . $a);
// }
$question_option->save();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire