VirtualNetwork.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Models;
  3. use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;
  4. /**
  5. * Class VirtualNetwork
  6. * @package ModulesGarden\ProxmoxAddon\App\Models
  7. * @property int $id
  8. * @property int $hosting_id
  9. * @property string $name
  10. * @property int $tag
  11. * @property string $pool
  12. * @property int $cidr
  13. * @property string $gateway
  14. * @property string $updated_at
  15. * @property string $created_at
  16. * @method static $this ofHostingId($hostingId)
  17. * @method $this ofId($id)
  18. * @property VirtualInterface[] $virtualInterfaces
  19. * @method $this ofTag($tag)
  20. */
  21. class VirtualNetwork extends ExtendedEloquentModel
  22. {
  23. protected $table = 'VirtualNetwork';
  24. protected $guarded = ['id'];
  25. /**
  26. *
  27. * @var array
  28. */
  29. protected $fillable = ['hosting_id', 'name', 'tag', 'pool','cidr', 'gateway'];
  30. public function scopeOfHostingId($query, $hostingId)
  31. {
  32. return $query->where("hosting_id", $hostingId);
  33. }
  34. public function scopeOfId($query, $id)
  35. {
  36. return $query->where("id", $id);
  37. }
  38. public function virtualInterfaces()
  39. {
  40. return $this->hasMany(VirtualInterface::class, "vn_id");
  41. }
  42. public function scopeOfTag($query, $tag)
  43. {
  44. return $query->where("tag", $tag);
  45. }
  46. }