| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Models;
- use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;
- /**
- * @property int $id
- * @property int $hosting_id
- * @property int $vn_id
- * @property int $vm_id
- * @property string $ip
- * @property int $ip_long
- * @property string $net
- * @property VirtualNetwork $virtualNetwork
- * @property VmModel $vmModel
- * @method static $this ofHostingId($hostingId)
- * @method $this ofVnId($hostingId)
- * @method $this ofVmId($id)
- * @method $this ofIp($ip)
- * @method $this notId($ids)
- * @method $this ofNetEmpty($ids)
- * @method $this ofNet($net)
- */
- class VirtualInterface extends ExtendedEloquentModel
- {
- /** @var string */
- protected $table = 'VirtualInterface';
- protected $fillable = [ 'hosting_id','vn_id', 'vm_id', 'ip', 'ip_long','net',
- ];
- public $timestamps = false;
- public function scopeOfHostingId($query, $hostingId)
- {
- return $query->where("hosting_id", $hostingId);
- }
- public function scopeOfVirtualNetworkId($query, $networkId)
- {
- return $query->where("vn_id", $networkId);
- }
- public function scopeOfVmId($query, $id)
- {
- return $query->where("vm_id", $id);
- }
- public function scopeOfVnId($query, $id)
- {
- return $query->where("vn_id", $id);
- }
- public function scopeOfIp($query, $ip)
- {
- return $query->where("ip", $ip);
- }
- public function virtualNetwork()
- {
- return $this->belongsTo(VirtualNetwork::class, "vn_id");
- }
- public function vmModel()
- {
- return $this->belongsTo(VmModel::class, "vm_id");
- }
- public function scopeNotId($query, $ips)
- {
- return $query->whereNotIn("id", $ips);
- }
- public function scopeOfNetEmpty($query)
- {
- return $query->where("net", "");
- }
- public function scopeOfNet($query , $net)
- {
- return $query->where("net", $net);
- }
- }
|