<?php


namespace ModulesGarden\ProxmoxAddon\App\Models;


use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;

/**
 * Class VirtualNetwork
 * @package ModulesGarden\ProxmoxAddon\App\Models
 * @property int $id
 * @property int $hosting_id
 * @property string $name
 * @property int $tag
 * @property string $pool
 * @property int $cidr
 * @property string $gateway
 * @property string $updated_at
 * @property string $created_at
 * @method static $this ofHostingId($hostingId)
 * @method $this ofId($id)
 * @property VirtualInterface[] $virtualInterfaces
 * @method $this ofTag($tag)
 */
class VirtualNetwork extends ExtendedEloquentModel
{

    protected $table = 'VirtualNetwork';

    protected $guarded = ['id'];

    /**
     *
     * @var array
     */
    protected $fillable = ['hosting_id', 'name', 'tag', 'pool','cidr', 'gateway'];

    public function scopeOfHostingId($query, $hostingId)
    {
        return $query->where("hosting_id", $hostingId);
    }

    public function scopeOfId($query, $id)
    {
        return $query->where("id", $id);
    }

    public function virtualInterfaces()
    {
        return $this->hasMany(VirtualInterface::class, "vn_id");
    }

    public function scopeOfTag($query, $tag)
    {
        return $query->where("tag", $tag);
    }
}