I have this route in web.php:
Route::get('student/evaluation/{evaluation}', [EvaluationController::class, 'getEvaluationQuestions'])->middleware('auth')->name('student.questionsevaluation');
And in my controller I have this condition, where $questionWasCompleted is boolean
if($questionWasCompleted){
return redirect()->route('student.questionsevaluation', $evaluation)->with('message', 'Question answered.');
}
How can I pass the $questionWasCompleted parameter in this redirect()->route() ?
CodePudding user response:
Pass a second with()
method in your controller like this:
return redirect()->route('student.questionsevaluation', $evaluation)
->with('message', 'Question answered.')
->with('question', $questionWasCompleted);
Alternatively, you can pass the both parameters in the same with()
method like this:
return redirect()->route('student.questionsevaluation', $evaluation)
->with(['message' => 'Question answered.',
'question' => $questionWasCompleted]);