result($message,$data,$code); } /** * @param string $message * @param int $code * @param null $data */ public function success($message='',$data=null,$code=0){ $this->result($message,$data,$code); } /** * @param string $msg * @param null $data * @param int $code * @param string|null $type * @param array $header * @param array $options */ private function result(string $msg, $data = null, int $code = 0, string $type = 'json', array $header = [], array $options = []) { $result = [ 'code' => $code, 'message' => $msg, 'data' => $data, ]; $code = 200; if (isset($header['statuscode'])) { $code = $header['statuscode']; unset($header['statuscode']); } $response = Response::create($result, $type, $code)->header($header)->options($options); throw new HttpResponseException($response); } }