Support the ongoing development of Laravel.io →
Session Views
Last updated 2 years ago.
0

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");
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

To complicated? Are you sure? You don't need to check if session set, you can define your own templates, what will you more?

Last updated 2 years ago.
0

Oh dear... I got the problem... typo :-S

Thanks for your help!!! I really appreciate!

Last updated 2 years ago.
0
@foreach (['danger', 'warning', 'success', 'info'] as $msg)
@if (Session::has(''alert-' . $msg'))
	<div class="alert alert-{{ $msg }}">{{ Session::get('alert-' . $msg) }}</div>
@endif
@endforeach
Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.