App::fatal(function($exception)
{
return Redirect::back()->with('msg', 'The Message');
}
In the view trying to access the msg with
Sessions::get('msg')
But nothing is getting rendered, am I doing something wrong here ?
欢迎各位兄弟 发布技术文章
这里的技术是共享的
App::fatal(function($exception)
{
return Redirect::back()->with('msg', 'The Message');
}
In the view trying to access the msg with
Sessions::get('msg')
But nothing is getting rendered, am I doing something wrong here ?
73 | Try
and inside your view call this
| |||
29 | Alternative approach would be Controller
View
| |||
11 | You have an error (misspelling):
Should be:
I think, now it should work, it does for me. | ||
8 | laravel 5:
Blade:
| |||
4 | I stopped writing this myself for laravel in favor of the Laracasts package that handles it all for you. It is really easy to use and keeps your code clean. There is even a laracast that covers how to use it. All you have to do: Pull in the package through Composer.
Include the service provider within app/config/app.php.
Add a facade alias to this same file at the bottom:
Pull the HTML into the view:
There is a close button on the right of the message. This relies on jQuery so make sure that is added before your bootstrap. optional changes: If you aren't using bootstrap or want to skip the include of the flash message and write the code yourself:
If you would like to view the HTML pulled in by If you need to modify the partials do:
The two package views will now be located in the `app/views/packages/laracasts/flash/' directory. | |||
3 | Just set the flash message and redirect to back from your controller functiion.
And then you can get the message in the view blade file.
| ||
1 | I faced with the same problem and this worked. Controller
View
| ||
1 | For Laravel 3 Just a heads up on @giannis christofakis answer; for anyone using Laravel 3 replace
with:
| ||
0 | In Laravel 5.4 the following worked for me:
| ||||||||||||
|
return Redirect::back()->with('msg', 'The Message');
how to get the "msg" here ? – Mudit Tuli Nov 7 '13 at 15:25Session::has('msg')
– giannis christofakis Nov 7 '13 at 15:28Session::has('msg')
and the 'msg' is not there. – Mudit Tuli Nov 7 '13 at 15:33->with()
theSession::flash()
. – giannis christofakis Nov 7 '13 at 15:48