Files
cycle_api/app/Service/ReplyService.php
2023-12-21 22:19:34 +08:00

29 lines
623 B
PHP

<?php
namespace App\Service;
use App\Const\Responses;
class ReplyService
{
static function reply($code, $msg, $data = []): \Illuminate\Http\JsonResponse
{
return response()->json([
'code' => $code,
'msg' => $msg,
'data' => $data,
]);
}
static function success($data = []): \Illuminate\Http\JsonResponse
{
return self::reply(Responses::CODE_SUCCESS, 'success', $data);
}
static function error($msg = 'error', $data = []): \Illuminate\Http\JsonResponse
{
return self::reply(Responses::CODE_ERROR, $msg, $data);
}
}