use the same syntax as before
you have
with(['messages', $messages]);
change to
with(['messages' => $messages]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
currently if someone visits mydomain.com/login they hit this entry in my web.php
Route::get('login', 'Auth\SessionController@showLoginForm')->name('login');
showLoginForm tests to see if they are already authenticated and shows a logged in page or sends them to a simple login form which is submits to:
Route::post('login', 'Auth\SessionController@authenticateUser');
My authenicateUser method, tests authentication and then:
return back()->with(['messages' => $messages]);
which sends the user back to /login where they are either redirected to logged in page (if authentication was successful) or shown the login form again but with errors. This all works fine as is.
But now I need something more sophisticated so I have changed:
return back()->with(['messages' => $messages]);
to
return redirect()->route('login')->with(['messages', $messages]);
and the form is shown but the messages are not.
Is there something I am missing?
use the same syntax as before
you have
with(['messages', $messages]);
change to
with(['messages' => $messages]);
Please or to participate in this conversation.