<?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;

/**
 * Description of RecoveryVm
 *
 * @author Pawel Kopec <pawelk@modulesgardne.com>
 * @property int $id
 * @property int $client_id
 * @property int $service_id
 * @property int $server_id
 * @property int $vserver_id
 * @property string $node
 * @property int $vmid
 * @property string $virtualization
 * @property string $config
 * @property string $status
 * @property string $dns
 * @property string $last_update
 * @property \ModulesGarden\ProxmoxAddon\Core\Models\Whmcs\Hosting $hosting Related hosting
 */
class RecoveryVm extends EloquentModel
{
    public $timestamps = false;
    protected $table = 'mg_proxmox_addon_recovery_vm_list';

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

    /**
     *
     * @var array
     */
    protected $fillable = ['client_id', 'service_id', 'server_id', 'vserver_id', 'node', 'vmid', 'virtualization', 'config', 'status', 'dns', 'last_update'];
    protected $softDelete = false;

    public function getConfig()
    {
        return json_decode($this->config, true);
    }

    public function getStatus()
    {
        return json_decode($this->status, true);
    }

    public function getDns()
    {
        return json_decode($this->dns, true);
    }

    /**
     * Get related hosting
     *
     * @return type
     */
    public function hosting()
    {
        return $this->belongsTo(\ModulesGarden\ProxmoxAddon\Core\Models\Whmcs\Hosting::class, "service_id");
    }
}
