request = is_null($request) ? Request::instance() : $request; } /** * 输出返回数据 * @param string $msg 提示消息内容 * @param string $code 业务状态码 * @param mixed $data 要返回的数据 * @param string $type 返回类型 JSON XML * @return Response */ public function response($msg, $code = 'SUCCESS', $data = [], $type = 'json') { $result = ['msg' => $msg, 'code' => $code, 'data' => $data, 'type' => strtolower($type)]; return Response::create($result, $type)->header(ToolsService::corsRequestHander())->code(200); } }