IpAddress.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Aug 22, 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\Models;
  20. use Illuminate\Database\Eloquent\model as EloquentModel;
  21. use ModulesGarden\ProxmoxAddon as main;
  22. /**
  23. * Description of RangeVm
  24. *
  25. * @author Pawel Kopec <pawelk@modulesgardne.com>
  26. * @property int $id
  27. * @property string $ip
  28. * @property string $type
  29. * @property string $mac_address
  30. * @property string $subnet_mask
  31. * @property string $gateway
  32. * @property int $cidr
  33. * @property int $sid
  34. * @property string $visualization
  35. * @property string $last_check
  36. * @property int $private
  37. * @property int $hosting_id
  38. * @property string $trunks
  39. * @property string $tag
  40. * @property string $node
  41. * @property main\Core\Models\Whmcs\Hosting $hosting related client hosting
  42. * @method static $this ofHostingId($hostingId)
  43. * @method $this ofTags($tags)
  44. * @method $this ofIp($ip)
  45. */
  46. class IpAddress extends EloquentModel
  47. {
  48. public $timestamps = false;
  49. /** @var string */
  50. protected $table = 'mg_proxmox_addon_ip';
  51. /** @var array */
  52. protected $fillable = ['id', 'ip', 'type', 'mac_address', 'subnet_mask', 'gateway', 'cidr', 'sid', 'visualization', 'last_check', 'private', 'hosting_id', 'trunks', 'tag', 'node'];
  53. /** @var int */
  54. protected $guarded = ['id'];
  55. protected $softDelete = true;
  56. public function hosting()
  57. {
  58. return $this->belongsTo(main\Core\Models\Whmcs\Hosting::class, 'hosting_id');
  59. }
  60. public function scopeOfHostingId($query, $hostingId)
  61. {
  62. return $query->where("hosting_id", $hostingId);
  63. }
  64. public function scopeOfTags($query, $tags)
  65. {
  66. return $query->whereIn("tag", $tags);
  67. }
  68. public function scopeOfIp($query, $ip)
  69. {
  70. return $query->where("ip", $ip);
  71. }
  72. public function scopePrivate($query)
  73. {
  74. return $query->where("private", 1);
  75. }
  76. }