cpu = $cpu; $this->product = $product; $this->telegram = new Telegram; } /** * Execute the job. * * @return void */ public function handle(ServiceVCenter $serviceVCenter) { $product = ModuleVmware::with([ 'IpAddress.Host.Datacenter.vCenter' ])->find($this->product); $serviceVCenter->token = $product->IpAddress->Host->Datacenter->vCenter->token; $serviceVCenter->apiUri = $product->IpAddress->Host->Datacenter->vCenter->host; $StatusVirtualMachine = $serviceVCenter->UpgradeCPUVirtualMachine($product->vmware_id, $this->cpu); if ($StatusVirtualMachine === "Login_Again") { $token = $serviceVCenter->loginServer($product->IpAddress->Host->Datacenter->vCenter); if ($token) { $product->IpAddress->Host->Datacenter->vCenter->update(['token' => $token]); $serviceVCenter->token = $token; } $StatusVirtualMachine = $serviceVCenter->UpgradeCPUVirtualMachine($product->vmware_id, $this->cpu); } if ($StatusVirtualMachine['error']) { throw new Exception(json_encode($StatusVirtualMachine['data'])); } } public function failed(Throwable $exception) { $this->telegram->SendErrorMessage($exception->getMessage()); } }