<?php
/**
 *
 * User: Artur Pilch <artur.pi@modulesgarden.com>
 * Date: 2018-08-06
 * Time: 15:55
 */

namespace ModulesGarden\HostingQuotaNotifications\App\Libs\ModuleSettings;

use ModulesGarden\HostingQuotaNotifications\Core\Models\ModuleSettings\Model as ModuleSettingsModel;

class Manage
{
    public static function getValueIfSetting($setting)
    {
        return ModuleSettingsModel::where('setting', '=', $setting)->value('value');
    }

    public static function updateValueIfSetting($setting, $update)
    {
        ModuleSettingsModel::where('setting', '=', $setting)->update($update);
    }

    public static function set($setting, $value)
    {
        $model = new ModuleSettingsModel();
        $model->setting = $setting;
        $model->value   = $value;
        $model->save();
    }
}