use IlluminateHttpResponse;
protected function failedValidation(IlluminateContractsValidationValidator $validator)
{
$response = new Response(['error' => $validator->errors()->first()], 422);
throw new ValidationException($validator, $response);
}
public function response(array $errors)
{
// Always return JSON.
return response()->json($errors, 422);
}