ResetBandwidth.php 2.2 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\Models\ModuleSettings;
  21. use ModulesGarden\ProxmoxAddon\App\Models\Whmcs\Hosting;
  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\UI\Validators\Validator;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\App\Controllers\Instances\AddonController;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits\WhmcsParams;
  28. class ResetBandwidth extends AddonController
  29. {
  30. use WhmcsParams;
  31. use ProductService;
  32. public function execute($params = null)
  33. {
  34. if(!ProxmoxAddonValidator::isInstalled()){
  35. return ProxmoxAddonValidator::failAsString();
  36. }
  37. (new AppParams())->initFromWhmcsParams();
  38. try
  39. {
  40. Hosting::where("id", $this->getWhmcsParamByKey('serviceid'))
  41. ->update(["bwusage" => 0]);
  42. return "success";
  43. }
  44. catch (\Exception $ex)
  45. {
  46. if (ModuleSettings::isDebug())
  47. {
  48. logModuleCall(
  49. 'ProxmoxVps',
  50. __CLASS__,
  51. [],
  52. null,
  53. $ex->getMessage() . " " . $ex->getTraceAsString()
  54. );
  55. }
  56. return $ex->getMessage();
  57. }
  58. }
  59. }