<?php

namespace ModulesGarden\ProxmoxAddon\App\Traits\Cloud;

use ModulesGarden\ProxmoxAddon\App\Models\VirtualInterface;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\VirtualInterfaceConverter;
use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;

trait VmNetwork
{
    protected function createNetwork(){
        //Network create & update
        $virtualInterfaces = VirtualInterface::ofHostingId($this->getWhmcsParamByKey('serviceid'))
            ->ofVmId(sl('Vm')->getVmModel()->id)
            ->ofNetEmpty()
            ->get();
        $vm =  null;
        if( sl('Vm')->hasVm()){
            $vm = sl('Vm')->getVm();
        }
        return (new VirtualInterfaceConverter( $virtualInterfaces, $vm))->asConfig();
    }
}