优化 错误处理

This commit is contained in:
iVampireSP.com 2022-12-25 21:39:19 +08:00
parent 172db3159a
commit ffc58d88ae
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -38,6 +38,13 @@ public function error($message = '', $code = 400): JsonResponse
public function apiResponse($data = [], $status = 200): JsonResponse
{
// if data is string, then it is error message
if (is_string($data)) {
$data = [
'message' => $data,
];
}
return response()->json($data, $status)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}