vendredi 26 février 2016

How to handle MethodNotAllowedHttpException

I'm looking to handle a MethodNotAllowedException. I've viewed other answers available on here that to create what i think should handle this in the exceptions/handler.php class. This is what i came up with.

  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);
  }

However where i used to get an error before, all i recieve now is a blank page on the page where i usually recieve an error and a user is not logged out nor are they redirected. Am i placing this handler in the right place and if so, is the function shown below correct?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire