我正在尝试使用成功/错误消息进行重定向。我目前有这段代码,但在这种情况下它似乎没有显示任何内容。
控制器:
return redirect()->action('Controller@index')->with('yes', 'Successfully subscribed');
查看:
@if (Session::get('yes'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{ Session::get('yes') }}
</div>
@endif
@if (Session::get('no'))
<div class="alert alert-danger" role="alert">
{{ Session::get('no') }}
</div>
@endif
答案 0 :(得分:0)
这对我有用:
@if ($message = session()->has('yes'))
<div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{ session()->get('yes') }}
</div>
@endif
@if ($message = session()->has('no'))
<div class="alert alert-danger" role="alert">
{{ session()->get('no') }}
</div>
@endif