Laravel 4如何在视图中显示Flash消息? [英] Laravel 4 how to display flash message in view?
本文介绍了Laravel 4如何在视图中显示Flash消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示我的Flash消息.
I'm trying to get my flash message to display.
这是在我的路由文件中
Route::post('users/groups/save', function(){
return Redirect::to('users/groups')->withInput()->with('success', 'Group Created Successfully.');
});
这是我的看法
{{ $success = Session::get('success') }}
@if($success)
<div class="alert-box success">
<h2>{{ $success }}</h2>
</div>
@endif
但是没有任何作用.
尝试此操作时,出现错误变量$成功未定义.但是它实际上也显示了Flash消息.
When I try this, I get an error Variable $success is undefined. But it actually shows the flash message too.
{{ Session::get('success') }}
@if($success)
<div class="alert-box success">
<h2>{{ $success }}</h2>
</div>
@endif
推荐答案
这对我有用
@if(Session::has('success'))
<div class="alert-box success">
<h2>{{ Session::get('success') }}</h2>
</div>
@endif
这篇关于Laravel 4如何在视图中显示Flash消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文