在app/Exceptions/Handler 中捕获路由不存在异常,返回不存在提示信息
public function render($request, Exception $e)
{
if($e instanceof NotFoundHttpException){
return json_encode(['status'=>0,'msg'=>'page not found!']);
}
return parent::render($request, $e);
}
引用地址
https://laracasts.com/discuss/channels/general-discussion/how-do-i-create-a-custom-404-error-page