error = config("errorcode"); } /** * HTTP请求成功时的数据返回 * * @param array $data * @param string $message * @return \Illuminate\Http\JsonResponse */ public function success($data = array(), $message = "success") { $return = array( 'code' => REQUEST_SUCCESS, 'message' => $message, 'data' => $data ); return response()->json($return); } /** * HTTP请求失败时错误信息返回 * * @param $code * @param string $codeMessage * @param null $message * @return \Illuminate\Http\JsonResponse */ public function fail($code, $codeMessage = "", $message = null) { return response()->json([ 'code' => (int)$code, "codeMessage" => $codeMessage, 'message' => $message ]); } /** * HTTP请求响应 * * @param $code * @param string $codeMessage * @param null $message * @return \Illuminate\Http\JsonResponse */ public function response($code, $codeMessage = "", $message = null) { return response()->json([ 'code' => (int)$code, "codeMessage" => $codeMessage, 'message' => $message ]); } }