如何在注册后在Laravel5.1认证中显示闪存消息?
发布于 2015-12-17 08:14:15
只需转到\照明\Foundation\Auth\寄存器用户
增列如下:
$request->session()->flash(“警报-成功”,“注册成功”);
RegistersUsers.php
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
Auth::login($this->create($request->all()));
$request->session()->flash('alert-success', 'Registration successful');
return redirect($this->redirectPath());
}在HTML刀片页面中,添加以下代码
@foreach (['danger', 'warning', 'success', 'info'] as $msg)
@if(Session::has('alert-' . $msg))
<div class="flash-message">
<p class="alert alert-{{ $msg }}">{{ Session::get('alert-' . $msg) }} <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a></p>
</div>
@endif
@endforeach我认为这不是一个优雅的解决方案,但它对我有效,希望这能帮助你。
https://stackoverflow.com/questions/34329625
复制相似问题