29 lines
627 B
PHP
29 lines
627 B
PHP
<?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);
|
|
}
|
|
|
|
}
|