Skip to content

更新数组函数6.x #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion laravel/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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) {
Expand Down