exception
This commit is contained in:
28
app/Service/ReplyService.php
Normal file
28
app/Service/ReplyService.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user