Laravel 5 flash data return on browse page

I did in the controller

Session::flash('message', 'Successfully updated!');

and in sight

@if (Session::has('message'))
                            <li>{!! Session::get('message') !!}</li>
                            @endif

However, nothing is passed in the view when I do var_dump (Session :: get ('message')); I can view the message, help me

+4
source share
2 answers

It should be: with "\" in your controller

\Session::flash('message', 'Successfully updated!');

And in your view, use session (), as in Laravel docs.

    @if (Session::has('message'))
        <li>{!! session('message') !!}</li>
   @endif

Check out the official Laravel docs Or This simple step-by-step tutorial on Flash messages in Laravel 5

+9
source

Assuming in the controller ... in the index () method you could put this code before returning the view Session::flash('message', 'Successfully updated!');

, . "\" , .

:

\Session::flash('message', 'Successfully updated!');
0

All Articles