diff --git a/laravel/app/Exceptions/Handler.php b/laravel/app/Exceptions/Handler.php index 962c261..907aec0 100644 --- a/laravel/app/Exceptions/Handler.php +++ b/laravel/app/Exceptions/Handler.php @@ -11,6 +11,7 @@ use Illuminate\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Tymon\JWTAuth\Exceptions\TokenBlacklistedException; +use Illuminate\Support\Arr; class Handler extends ExceptionHandler { @@ -59,7 +60,7 @@ public function render($request, Exception $exception) if ($exception instanceof ValidationException) { // $code = 1104; // return response(['error' => array_first(array_collapse($exception->errors()))], 400); - return $this->getResultByCode(1104, array_first(array_collapse($exception->errors()))); + return $this->getResultByCode(1104, Arr::first(Arr::collapse($exception->errors()))); } // 用户认证的异常,我们需要返回 401 的 http code 和错误信息 if ($exception instanceof UnauthorizedHttpException) {