From d6c11cbc5021239d87783ab67a211a97435f47c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=89=E4=BB=95=E9=91=AB?= Date: Thu, 22 Feb 2024 17:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0sql=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 ++- src/Support/Cores/JsonResponse.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c8ab5dc6..c48caad1 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "require": { "php": ">=8.0", "illuminate/support": "~9|~10", - "iconify/json": "*" + "iconify/json": "*", + "slowlyo/laravel-support": "*" }, "autoload": { "psr-4": { diff --git a/src/Support/Cores/JsonResponse.php b/src/Support/Cores/JsonResponse.php index 0fef4a9e..5a8b1a1c 100644 --- a/src/Support/Cores/JsonResponse.php +++ b/src/Support/Cores/JsonResponse.php @@ -11,11 +11,19 @@ class JsonResponse 'status' => 0, 'msg' => '', 'doNotDisplayToast' => 0, + 'sql' => [], ]; + public function __construct() + { + if (config('app.debug')) { + $this->additionalData['sql'] = sql_record(); + } + } + /** * @param string $message - * @param null $data + * @param null $data * * @return \Illuminate\Http\JsonResponse */ @@ -27,7 +35,7 @@ public function fail(string $message = 'Service error', $data = null): \Illumina } /** - * @param null $data + * @param null $data * @param string $message * * @return \Illuminate\Http\JsonResponse|JsonResource