diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index b232b8956d..3e35005011 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -117,4 +117,16 @@ class Handler extends ExceptionHandler return redirect()->guest('login'); } + + /** + * Convert a validation exception into a JSON response. + * + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Validation\ValidationException $exception + * @return \Illuminate\Http\JsonResponse + */ + protected function invalidJson($request, ValidationException $exception) + { + return response()->json($exception->errors(), $exception->status); + } }