I have 4 radio button and the user can choose a single choice of them, I want to check if this choice exists or not in the table question(this table contains the text of question, thei options, and the correcte answer) if it exists I want to increment the fields points Which is in the table test, and for do that the controller contains :
$userChoise = $request->answer;
$test = new Test;
$questions = DB::table('question')->get();
foreach ($questions as $question) {
if ($question->correcte == $userChoise) {
$test->nbr_points = 10;
$test->save();
}else{
$test->nbr_points = 0;
$test->save();
}
}
the problem is that it does not take into consideration what is in the condition if it still runs the else processing