Hi,
I have a problem with a redirect -> with message
In my controller, I have a return redirect as below :
return redirect(route('multiHikes.index'))->with('message', 'Hikes non créé');
In my view (createMultiHikes), I have this :
@if (session('message')) <div class="alert alert-success"> {{ session('message') }} </div> @endif
The route "multiHikes.index" return the view "createMultiHikes"
when I debug the return, in the _flash, I do have a message created with its contents... but when I debug the "session::all()" in the view, it's empty
I don't understand why I can't get the message out in the view. Thank you for your answers.
Try this:
return redirect()->route('multiHike.index')->with('message', 'Hello');
Or
return redirect()->route('multiHike.index', ['messag' => 'Your messge']);
Also see the examples on the docs: Redirecting named routes
I personally never pass the argument for a redirect.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community