优化 错误处理
This commit is contained in:
parent
172db3159a
commit
ffc58d88ae
@ -38,6 +38,13 @@ public function error($message = '', $code = 400): JsonResponse
|
|||||||
|
|
||||||
public function apiResponse($data = [], $status = 200): 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);
|
return response()->json($data, $status)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user