如何返回带有Flash消息的视图?

编程入门 行业动态 更新时间:2024-10-26 12:22:13
本文介绍了如何返回带有Flash消息的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要的是这个

return view('protected.standardUser.includes.documents',compact('documents'))->with('successMsg','Property is updated .');

我可以这样使用它:

@if(Session::has('successMsg')) <div class="alert alert-success"> {{ Session::get('successMsg') }}</div> @endif

有什么建议吗?

推荐答案

似乎您正在混用两种不同的方式将数据传递给视图,我猜这就是问题所在. 文档似乎表明这是一种或另一种情况.您似乎还混淆了view()->with()和redirect()->with(),它们的工作方式不同.试试这个:

It looks like you're mixing two different ways of passing data to a view, which I'm guessing is the problem. The documentation seems to indicate it's a one or the other type situation. You also seem to be mixing up view()->with() and redirect()->with(), which work differently. Try this:

return view('protected.standardUser.includes.documents')->with('documents', $documents)->with('successMsg','Property is updated .');

还有

@if(!empty($successMsg)) <div class="alert alert-success"> {{ $successMsg }}</div> @endif

更多推荐

如何返回带有Flash消息的视图?

本文发布于:2023-10-18 12:09:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504192.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   消息   Flash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!