Skip to content

Commit

Permalink
接口返回增加sql记录
Browse files Browse the repository at this point in the history
  • Loading branch information
slowlyo committed Feb 22, 2024
1 parent 894ab6c commit d6c11cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"require": {
"php": ">=8.0",
"illuminate/support": "~9|~10",
"iconify/json": "*"
"iconify/json": "*",
"slowlyo/laravel-support": "*"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 10 additions & 2 deletions src/Support/Cores/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand Down

0 comments on commit d6c11cb

Please sign in to comment.