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\UI\Settings\Providers; use ModulesGarden\ProxmoxAddon as main; /** * Description of SettingProvider * * @author Pawel Kopec */ class SettingProvider extends main\Core\UI\Widget\Forms\DataProviders\BaseDataProvider { public function read() { $this->data = []; $this->data['proxmoxVPSMinimumVMID'] = main\Core\Models\Whmcs\Configuration::where("setting", "proxmoxVPSMinimumVMID")->value('value'); $this->data['vmsWeight'] = main\Core\Models\ModuleSettings\Model::where("setting", 'vmsWeight')->value("value"); $this->data['cpuWeight'] = main\Core\Models\ModuleSettings\Model::where("setting", "cpuWeight")->value("value"); $this->data['diskWeight'] = main\Core\Models\ModuleSettings\Model::where("setting", 'diskWeight')->value("value"); $this->data['ramWeight'] = main\Core\Models\ModuleSettings\Model::where("setting", 'ramWeight')->value("value"); $this->data['debug'] = main\Core\Models\ModuleSettings\Model::where("setting", 'debug')->value("value"); } public function update() { if(main\Core\Models\Whmcs\Configuration::where("setting", "proxmoxVPSMinimumVMID")->count()){ main\Core\Models\Whmcs\Configuration::where("setting", "proxmoxVPSMinimumVMID") ->update(['value' => $this->formData['proxmoxVPSMinimumVMID']]); }else{ main\Core\Models\Whmcs\Configuration::where("setting", "proxmoxVPSMinimumVMID") ->insert(["setting" => "proxmoxVPSMinimumVMID",'value' => $this->formData['proxmoxVPSMinimumVMID']]); } $filable = ["vmsWeight", "cpuWeight", "diskWeight", "ramWeight", 'debug']; foreach ($filable as $key) { $entity = main\Core\Models\ModuleSettings\Model::where("setting", $key)->first(); if (!$entity) { $entity = new main\Core\Models\ModuleSettings\Model(); } $entity->fill(['setting'=> $key, "value" => $this->formData[$key]]) ->save(); } } }