AdminServicesTabFields.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**********************************************************************
  3. * ProxmoxVPS developed. (26.03.19)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. **********************************************************************/
  19. namespace ModulesGarden\Servers\ProxmoxVps\App\Http\Actions;
  20. use ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update\AddonUpgradeService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  22. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  23. use ModulesGarden\Servers\ProxmoxVps\App\Helpers\AppParams;
  24. use ModulesGarden\Servers\ProxmoxVps\App\Helpers\ProxmoxAddonValidator;
  25. use ModulesGarden\Servers\ProxmoxVps\App\Http\Admin\Home;
  26. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\Validator;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\App\Controllers\Instances\AddonController;
  28. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits\WhmcsParams;
  29. class AdminServicesTabFields extends AddonController
  30. {
  31. use WhmcsParams;
  32. use ProductService;
  33. use ApiService;
  34. /**
  35. * @var AddonUpgradeService
  36. */
  37. private $addonUpgradeService;
  38. public function execute($params = null)
  39. {
  40. $action = $this->getRequestValue('mg-action') ? $this->request->get('mg-action') : 'index';
  41. if ($params['status'] != "Active" || !$params["customfields"]["vmid"])
  42. {
  43. return [];
  44. }
  45. try {
  46. ProxmoxAddonValidator::isInstalledOrFail();
  47. (new AppParams())->initFromWhmcsParams();
  48. $this->addonUpgradeService = new AddonUpgradeService();
  49. $this->addonUpgradeService->run();
  50. $this->vm()->status();
  51. return [Home::class, $action];
  52. } catch (\Exception $ex) {
  53. return ["Error" => "<span style='color: red'>" . $ex->getMessage() . "</span>"];
  54. }
  55. }
  56. }