Can someone explain why the code below does not work when redirecting to another page?
return redirect()->route('homepage')->with('message', 'I am so frustrated.');
The forwarding works as expected, but the message does not appear.
The view looks like this:
@if ( session()->has('message') )
<div class="alert alert-success alert-dismissable">{{ session()->get('message') }}</div>
@endif
When I change it to:
return redirect()->route('contact')->with('message', 'I am so frustrated.');
which matches redirect () → back () , everything works fine and a message is displayed. What is the difference between forwarding back()and to()another view?
source
share