Laravel 使用() 消息重定向返回 [英] Laravel Redirect Back with() Message
本文介绍了Laravel 使用() 消息重定向返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当出现致命错误时,我试图重定向到带有消息的上一页.
I am trying to redirect to the previous page with a message when there is a fatal error.
App::fatal(function($exception)
{
return Redirect::back()->with('msg', 'The Message');
}
在视图中尝试使用
Sessions::get('msg')
但是什么都没有渲染,我在这里做错了吗?
But nothing is getting rendered, am I doing something wrong here?
推荐答案
尝试
return Redirect::back()->withErrors(['msg' => 'The Message']);
在你的视图中调用这个
@if($errors->any())
<h4>{{$errors->first()}}</h4>
@endif
这篇关于Laravel 使用() 消息重定向返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文