<?php

namespace ModulesGarden\Servers\ProxmoxCloudVps\App\Factory;

use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits\RequestObjectHandler;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits\WhmcsParams;

class VmModelFactory
{
    use WhmcsParams;
    use RequestObjectHandler;

    /**
     * @return VmModel
     */
    public function fromRequest(){
        return VmModel::ofHostingId($this->getWhmcsParamByKey('serviceid'))
                 ->ofId($this->getRequestValue('vm'))
                 ->firstOrFail();
    }

}