Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass multiple data with redirect()->route() in Laravel 9

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() ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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]);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading