VmIpAddress.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product 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\ProxmoxAddon\App\Models;
  20. use ModulesGarden\ProxmoxAddon\App\Models\Whmcs\Hosting;
  21. use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;
  22. /**
  23. * @property int $id
  24. * @property int $hosting_id
  25. * @property int $server_id
  26. * @property string $ip
  27. * @property string $mac_address
  28. * @property string $subnet_mask
  29. * @property string $gateway
  30. * @property int $cidr
  31. * @property int $trunks
  32. * @property int $tag
  33. * @property string $net
  34. * @property int $vm_id
  35. * @method static $this ofHostingId($hostingId)
  36. * @method $this ofIp($ip)
  37. * @method $this ofIp4()
  38. * @method $this ofIp6()
  39. * @method $this ofNetNull()
  40. * @method $this ofNetNotNull()
  41. * @method $this ofNet($net)
  42. * @method $this limit($limit)
  43. * @method $this orderByIdDesc()
  44. * @method $this orderByIdAsc()
  45. * @method $this ofVmId($id)
  46. * @method $this notIdIn($ids)
  47. * @property Hosting $hosting
  48. * @property VmModel $vmModel
  49. */
  50. class VmIpAddress extends ExtendedEloquentModel
  51. {
  52. public $timestamps = false;
  53. /** @var string */
  54. protected $table = 'VmIpAddress';
  55. protected $fillable = [ 'hosting_id', "vm_id", 'server_id', 'ip', 'mac_address', 'subnet_mask', 'gateway', 'cidr', 'trunks', 'tag', 'net'];
  56. public function hosting()
  57. {
  58. return $this->belongsTo(Hosting::class, 'hosting_id');
  59. }
  60. public function vmModel()
  61. {
  62. return $this->belongsTo(VmModel::class, 'vm_id');
  63. }
  64. public function scopeOfHostingId($query, $hostingId)
  65. {
  66. return $query->where("hosting_id", $hostingId);
  67. }
  68. public function scopeOfIp($query, $ip)
  69. {
  70. return $query->where("ip", $ip);
  71. }
  72. public function scopeOfIp4($query)
  73. {
  74. return $query->where('ip', 'LIKE', '%.%');
  75. }
  76. public function scopeOfIp6($query)
  77. {
  78. return $query->where('ip', 'LIKE', '%:%');
  79. }
  80. public function scopeOfNetNull($query)
  81. {
  82. return $query->whereNull('net');
  83. }
  84. public function scopeOfNetNotNull($query)
  85. {
  86. return $query->whereNotNull('net');
  87. }
  88. public function scopeOfNet($query, $net)
  89. {
  90. return $query->where('net', $net);
  91. }
  92. public function scopeOrderByIdDesc($query)
  93. {
  94. return $query->orderBy('id', "DESC");
  95. }
  96. public function scopeOrderByIdAsc($query)
  97. {
  98. return $query->orderBy('id', "ASC");
  99. }
  100. public function scopeOfVmId($query, $id)
  101. {
  102. return $query->where('vm_id', $id);
  103. }
  104. public function scopeNotIdIn($query, $ids)
  105. {
  106. return $query->whereNotIn("vm_id", $ids);
  107. }
  108. public function scopeOfVmIdNull($query)
  109. {
  110. return $query->whereNull('vm_id');
  111. }
  112. }