actionElementId && $this->actionElementId != "diskDataTable") { $this->data['id'] = $this->actionElementId; $this->data['name'] = VmModel::where("id", $this->actionElementId)->value("name"); } } public function update() { } public function delete() { //init proxmox addon params (new AppParams())->initFromWhmcsParams(); //get vm model $vmModel = VmModel::ofHostingId($this->getWhmcsParamByKey('serviceid')) ->ofId($this->formData['id'])->firstOrFail(); $this->api(); try { $status = (new VmFactory())->fromVmModel($vmModel)->status()['status']; if (!($status=='running'||$status=='stopped')) { return (new HtmlDataJsonResponse()) ->setStatusError() ->setMessageAndTranslate('The Virtual Machine cannot be deleted in an unknown state'); } } catch (\Exception $ex) { return (new HtmlDataJsonResponse()) ->setStatusError() ->setMessageAndTranslate('Error deleting Virtual Machine'); } //destory vm (new CloudService())->delete($vmModel); return (new HtmlDataJsonResponse()) ->setStatusSuccess() ->setMessageAndTranslate('The Virtual Machine has been deleted successfully') ->setCallBackFunction('pmActivateCreateVMButton'); } }