RangeVmRepository.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Sep 21, 2018)
  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\ProxmoxAddon\App\Repositories;
  20. use ModulesGarden\ProxmoxAddon as main;
  21. /**
  22. * Description of RangeVmRepository
  23. *
  24. * @author Pawel Kopec <pawelk@modulesgardne.com>
  25. */
  26. class RangeVmRepository
  27. {
  28. private $serverId;
  29. private $min;
  30. private $max;
  31. /**
  32. *
  33. * @var main\App\Models\RangeVm
  34. */
  35. private $model;
  36. public function __construct($serverId)
  37. {
  38. $this->serverId = $serverId;
  39. $this->model = main\App\Models\RangeVm::where('server_id', $this->serverId)->first();
  40. if ($this->model)
  41. {
  42. $this->min = $this->model->vmid_from;
  43. $this->max = $this->model->vmid_to;
  44. }
  45. if (!$this->min)
  46. {
  47. $this->min = main\Core\Models\Whmcs\Configuration::where("setting", "proxmoxVPSMinimumVMID")->value('value');
  48. }
  49. }
  50. public function has()
  51. {
  52. return $this->min > 0 || $this->max > 1;
  53. }
  54. public function getMin()
  55. {
  56. return $this->min;
  57. }
  58. public function setMin($min)
  59. {
  60. $this->min = $min;
  61. return $this;
  62. }
  63. public function getMax()
  64. {
  65. return $this->max;
  66. }
  67. public function setMax($max)
  68. {
  69. $this->max = $max;
  70. return $this;
  71. }
  72. }