Laravel 5 redirects a message

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?

+4
source share
1 answer

Laravel 5.2, , , , web.

contact web, homepage , .

+5

Source: https://habr.com/ru/post/1622496/


All Articles