handleValidationException($exception, $ajax); } catch(AuthException $exception) { return $this->handleAuthException($exception, $ajax); } } protected function handleValidationException(ValidationException $exception, $ajax = false) { if($ajax) { return Response::json(array('errors' => $exception->errors()), 422); } else { return Redirect::back()->withInput()->withErrors($exception->errors()); } } protected function handleAuthException(AuthException $exception, $ajax = false) { if(Request::isAjax()) { return Response::json($exception->getMessage(), 403); } else { App::abort(403); } } }