From fabd99b40d960e30fd12abda294be582dbe7adb9 Mon Sep 17 00:00:00 2001 From: jiannei Date: Fri, 19 Mar 2021 22:40:43 +0800 Subject: [PATCH] feat: Add config for fail http status #19 --- config/response.php | 2 ++ src/Response.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/response.php b/config/response.php index 61ff491..9f3dd76 100644 --- a/config/response.php +++ b/config/response.php @@ -12,6 +12,8 @@ return [ 'enum' => \Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum::class, + 'error_code' => \Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum::HTTP_INTERNAL_SERVER_ERROR, + 'validation_error_code' => \Jiannei\Enum\Laravel\Repositories\Enums\HttpStatusCodeEnum::HTTP_UNPROCESSABLE_ENTITY, 'format' => [ diff --git a/src/Response.php b/src/Response.php index 1cee874..7994c76 100644 --- a/src/Response.php +++ b/src/Response.php @@ -145,7 +145,7 @@ public function fail(string $message = '', int $code = 500, $errors = null, arra { $response = $this->response( $this->formatData(null, $message, $code, $errors), - $code, + Config::get('response.error_code', $code), $header, $options );