Quantcast
Channel: Laravel 4 how to display flash message in view? - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by foxfarrier for Laravel 4 how to display flash message in view?

$
0
0

Laravel 4.2 Personally i use

Session::flash('key', 'value');
return Redirect::to('some/url');

then in the view id first check if there is a session of that key in the view

@if(Session::has('key'))
   {{Session::get('key')}} //this prints out the message or your 'value' in the session::flash method
@endif

it works for me most of the time and i usually have that blade template integrated into my view just so i can push success messages to the view from my codes.

please do note that it is stated in the documentation that "Sometimes you may wish to store items in the session only for the next request. You may do so using the Session::flash method" so yes it expires after the next page.

hope this helps


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>