控制器调用

        public function json(){
            if (request()->isPost()) {
                return jsonData(1,'转换成功',数据(可不填));
    } 
   } 

 

公共方法

/*
 * 返回统一格式
 */
function jsonData($code = 1, $msg = '', $data = [])
{
    //code 0代表错误,1代表成功
    $codeV = ['error','success'];
    return json_encode(['code' => $codeV[$code],'msg'=>$msg,'data'=>$data],JSON_UNESCAPED_UNICODE);
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 1970-01-01
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2021-09-29
  • 2021-12-26
  • 2022-01-28
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案