| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Services;
- use MGProvision\Proxmox\v2 as proxmox;
- use ModulesGarden\ProxmoxAddon as main;
- /**
- * Doe labels datatable controler
- *
- */
- trait BaseService
- {
- private $serverId;
- /**
- *
- * @var main\Core\Models\Whmcs\Server
- */
- private $server;
- private $api;
- /**
- *
- * @return proxmox\Api
- */
- public function getApi()
- {
- if ($this->api)
- {
- return $this->api;
- }
- $host = $this->getServer()->ipaddress ? $this->getServer()->ipaddress : $this->getServer()->hostname;
- if(is_numeric($this->getServer()->port)){
- $host .=":".$this->getServer()->port;
- }
- $password = html_entity_decode(decrypt($this->getServer()->password),ENT_QUOTES);
- return $this->api = new proxmox\Api($host, $this->getServer()->username, $this->getServer()->accesshash,$password );
- }
- /**
- *
- * @return main\Core\Models\Whmcs\Server
- */
- public function getServer()
- {
- if ($this->server)
- {
- return $this->server;
- }
- return $this->server = main\Core\Models\Whmcs\Server::findOrFail($this->getServerId());
- }
- public function getServerId()
- {
- return $this->serverId;
- }
- public function setServerId($serverId)
- {
- $this->serverId = $serverId;
- return $this;
- }
- }
|