如何返回带有Flash消息的视图? [英] How to return view with flash message?

查看:64
本文介绍了如何返回带有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消息的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆