Handle JSON validation errors like 5.4

This commit is contained in:
snipe 2019-05-24 00:46:30 -07:00
parent bf93e8cc32
commit 96e2d74ae3

View file

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