Php 如何处理MethodNotAllowedHttpException

Php 如何处理MethodNotAllowedHttpException,php,exception-handling,laravel-5.1,laravel-5.2,Php,Exception Handling,Laravel 5.1,Laravel 5.2,我想处理一个MethodNotAllowedException。我在这里查看了其他可用的答案,以创建我认为应该在exceptions/handler.php类中处理的内容。这就是我想到的 public function render($request, Exception $e) { if ($e instanceof MethodNotAllowedHttpException) { \Auth::logout(); \Session::flu

我想处理一个MethodNotAllowedException。我在这里查看了其他可用的答案,以创建我认为应该在exceptions/handler.php类中处理的内容。这就是我想到的

  public function render($request, Exception $e)
  {

    if ($e instanceof MethodNotAllowedHttpException) {

        \Auth::logout();
        \Session::flush();
        return redirect()->('/')->withErrors(['error' => 'Something went wrong']);
    }
    return parent::render($request, $e);
  }
然而,在我以前遇到错误的地方,我现在收到的只是页面上的一个空白页,在那里我通常会收到一个错误,用户没有注销,也没有被重定向。我是否将此处理程序放置在正确的位置?如果是,下面显示的函数是否正确

谢谢