Laravel 5重定向出错,无法在Handler.php中工作



我想重定向到一个显示Handler.php错误消息的页面。我的实现将成功重定向,但不会在页面上显示消息。

重定向函数 (Handler.php(

public function render($request, Exception $exception) {
if ($exception instanceof IlluminateHttpExceptionsPostTooLargeException)
return Redirect::to('administrator/media')->with('errorMessage', 'File size is too big.');
// Code omitted for brevity
}

查看(media.blade.php(

@if (Session::get('errorMessage')) 
<div class="m-t-20">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-check"></i> Error!!</h4>                            
<p>{{ Session::get('errorMessage') }}</p>
</div>
</div>
</div>
@endif

试试这个。看起来像是在中间件中重定向。无论如何,这应该有效:

public function render($request, Exception $exception) {
if ($exception instanceof IlluminateHttpExceptionsPostTooLargeException)
{
$request->session()->flash('errorMessage', 'File size is too big.');
return Redirect::to('administrator/media');
}
// Code omitted for brevity

}

最新更新