如何通过 Flash 消息返回视图?

2023-12-30

我需要的是这样的:

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

有什么建议吗?


看起来您正在混合两种不同的方式将数据传递到视图,我猜这就是问题所在。文档 https://laravel.com/docs/5.4/views#passing-data-to-views似乎表明这是一种或另一种类型的情况。你好像也搞混了view()->with() and redirect()->with(),其工作方式不同。尝试这个:

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

And

@if(!empty($successMsg))
  <div class="alert alert-success"> {{ $successMsg }}</div>
@endif
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 Flash 消息返回视图? 的相关文章

随机推荐