initIds('virtualNetworkSection'); $this->initFields(); } public function initFields() { //virtualNetwork $this->customTplVars['virtualNetwork'] = ["public" => sl('lang')->abtr('Public')]; //ips $this->customTplVars['ips']=[]; //Public $this->customTplVars['ipSelected'] =null; foreach (VmIpAddress::ofHostingId($this->getWhmcsParamByKey('serviceid'))->ofVmIdNull()->get() as $ip) { if(!$this->customTplVars['ipSelected'] ){ $this->customTplVars['ipSelected'] = $ip->ip; } $this->customTplVars['ips'][] =[ "networkId" => "public", "ip" => $ip->ip, "id" => $ip->id ]; } if(empty($this->customTplVars['ips'])){ unset($this->customTplVars['virtualNetwork']['public']); } //private foreach (VirtualNetwork::ofHostingId($this->getWhmcsParamByKey('serviceid'))->get() as $vn) { $this->customTplVars['virtualNetwork'][$vn->id] = $vn->name; $ipRange = new Ipv4Range($vn->pool, $vn->cidr); $ipRange->setLimit(255); $ipRange->disableIpAddresses( $vn->virtualInterfaces->pluck('ip')->toArray()); foreach ( $ipRange->get() as $ip ){ $this->customTplVars['ips'][]=[ "networkId" => $vn->id, "ip" => $ip, ]; } } } }