<?php

/* * ********************************************************************
 * ProxmoxAddon product developed. (Aug 22, 2018)
 * *
 *
 *  CREATED BY MODULESGARDEN       ->       http://modulesgarden.com
 *  CONTACT                        ->       contact@modulesgarden.com
 *
 *
 * This software is furnished under a license and may be used and copied
 * only  in  accordance  with  the  terms  of such  license and with the
 * inclusion of the above copyright notice.  This software  or any other
 * copies thereof may not be provided or otherwise made available to any
 * other person.  No title to and  ownership of the  software is  hereby
 * transferred.
 *
 *
 * ******************************************************************** */

namespace ModulesGarden\ProxmoxAddon\App\Models;

use Illuminate\Database\Eloquent\model as EloquentModel;
use ModulesGarden\ProxmoxAddon as main;

/**
 * Description of RangeVm
 *
 * @author Pawel Kopec <pawelk@modulesgardne.com>
 * @property main\Core\Models\Whmcs\Server $server
 * @property int $vmid_from
 * @property int $vmid_to
 * @property \ModulesGarden\ProxmoxAddon\Core\Models\Whmcs\Server $server
 * @method static this ofServerId($serverId)
 */
class RangeVm extends EloquentModel
{
    public $timestamps = false;
    protected $primaryKey = 'server_id';
    protected $table = 'mg_proxmox_vmranges';

    /**
     *
     *
     */
    protected $guarded = ['server_id'];

    /**
     *
     * @var array
     */
    protected $fillable = ['server_id', 'vmid_from', 'vmid_to'];
    protected $softDelete = false;

    public function server()
    {
        return $this->belongsTo(main\Core\Models\Whmcs\Server::class, 'server_id');
    }

    public function scopeOfServerId($query, $serverId)
    {
        return $query->where("server_id", $serverId);
    }
}
