feat(BaseLikeController): 对象数据转为数组

This commit is contained in:
mkm 2024-07-26 11:36:53 +08:00
parent 4e67edcc77
commit 7264546a3a

View File

@ -22,8 +22,11 @@ class BaseLikeController extends BaseController
* @author 乔峰
* @date 2021/12/27 14:21
*/
protected function success(string $msg = 'success', array $data = [], int $code = 1, int $show = 0)
protected function success(string $msg = 'success', $data = [], int $code = 1, int $show = 0)
{
if(is_object($data)){
$data = $data->toArray();
}
return JsonService::success($msg, $data, $code, $show);
}
@ -36,6 +39,9 @@ class BaseLikeController extends BaseController
*/
protected function data($data)
{
if(is_object($data)){
$data = $data->toArray();
}
return JsonService::data($data);
}