Hi there!
I have a code that works fine. It displays flash messages. This is what you find in my view:
@if (Session::has('message'))
<div class="alert alert-info">{{ Session::get('message') }}</div>
@endif
And this is how my controller creates the view:
// redirect
Session::flash('message', 'My message');
return Redirect::to('root/mypage');
But when I change the word "message" to "my_message" in both code-snippets above, the whole thing doesn't work any more... why??? I need to give them a new name to distinguish different messages displayed in my view....
Thank you for your help!
You can use my Package if you want https://packagist.org/packages/levare/notify
in your view you insert
{{Notify::parseAll()}}
and in your controller you call:
Notify::flashDanger("Your Message");
Notify::flashSuccess("Your Message");
Notify::flashWarning("Your Message");
Notify::flashInfo("Your Message");
Hello!
Thank you very much. But I think this is too complicated :-) I just need to rename my messages .
Example: A controller A redirects, I define message "message1"
// redirect
Session::flash('message1', 'My message');
return Redirect::to('root/mypage');
this message is displayed in my view in a specific place like this:
@if (Session::has('message1'))
<div class="alert alert-info">{{ Session::get('message1') }}</div>
@endif
An other controller B redirects, I define message "message2"
// redirect
Session::flash('message2', 'My message');
return Redirect::to('root/mypage');
this message is displayed in my view in a specific place like this:
@if (Session::has('message2'))
<div class="alert alert-info">{{ Session::get('message1') }}</div>
@endif
But this wont work... why?
To complicated? Are you sure? You don't need to check if session set, you can define your own templates, what will you more?
Oh dear... I got the problem... typo :-S
Thanks for your help!!! I really appreciate!
@foreach (['danger', 'warning', 'success', 'info'] as $msg)
@if (Session::has(''alert-' . $msg'))
<div class="alert alert-{{ $msg }}">{{ Session::get('alert-' . $msg) }}</div>
@endif
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community