diff --git a/app/Helpers/ApiResponse.php b/app/Helpers/ApiResponse.php index 3ad65ad..c765082 100644 --- a/app/Helpers/ApiResponse.php +++ b/app/Helpers/ApiResponse.php @@ -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); }