[我试图做的是从异常处理程序类重定向回页面时在会话中获取消息,当我收到'PostTooLargeException'时,它应该返回页面并显示一条消息。
处理程序类中的If语句
public function render($request, Exception $exception)
{
//...
if ($exception instanceof PostTooLargeException) {
$test = redirect()->route('clientbank.create')->with('message', 'File too large!'); //Cannot get message
return $test;
//dump($gg);
dump(session('message'));
dd('stop');
}
// this will still show the error if there is any in your code.
return parent::render($request, $exception);
}
}
在dump(session('message'));
中,我可以看到消息。
在刀片页面中
@elseif(session('message'))
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ session('message') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
@endif
在控制器中
public function create()
{
dump(session('message')); <-- getting null !!!
return view('clinetbank.bank.cratebank');
}
我想做的是使用empyt(session('message')
我总是得到一个空会话。
也,我尝试this问题,但对我不起作用。
我使用laravel 5.8
任何想法,请?。
谢谢大家。