| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- /* * ********************************************************************
- * ProxmoxAddon product developed. (Sep 12, 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\UI\Settings\Providers;
- use ModulesGarden\ProxmoxAddon as main;
- /**
- * Description of SettingProvider
- *
- * @author Pawel Kopec <pawelk@modulesgardne.com>
- */
- 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();
- }
- }
- }
|