| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Vms\Providers;
- use MGProvision\Proxmox\v2\VmFactory;
- use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
- use ModulesGarden\ProxmoxAddon\App\Services\CloudService;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers\AppParams;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
- class DeleteVmProvider extends BaseDataProvider implements ClientArea
- {
- use ApiService;
- public function read()
- {
- if ($this->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();
- $status = (new VmFactory())->fromVmModel($vmModel)->status()['status'];
-
- //destory vm
- logModuleCall(
- 'proxmoxCloud',
- __FUNCTION__,
- $status,
- 'Debug',
- $vmModel
- );
- // (new CloudService())->delete($vmModel);
- return (new HtmlDataJsonResponse())
- ->setStatusSuccess()
- ->setMessageAndTranslate('The Virtual Machine has been deleted successfully')
- ->setCallBackFunction('pmActivateCreateVMButton');
- }
- }
|