add service dir

This commit is contained in:
cano
2024-03-26 20:07:19 +08:00
parent 6ce37d789f
commit 01e93acdd8
20 changed files with 24 additions and 30 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\Service\Api;
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);
}
}