HEX
Server: LiteSpeed
System: Linux premium260.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: aliazzsr (627)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/aliazzsr/api.crm.vqode.com/models/core/Setting.php
<?php
namespace app\models\core;

use app\components\BaseModel;
use app\components\behaviors\EulaBehavior;
use app\models\enums\SettingEnum;

class Setting extends BaseModel
{
    public $major = false;

    public static function tableName()
    {
        return 'setting';
    }

    public static function primaryKey()
    {
        return ['name'];
    }

    public function rules()
    {
        return [
            ['name', 'required'],
            ['name', 'in', 'range' => SettingEnum::getConstantsByName(), 'message' => 'Unknown setting name'],
            [['name', 'value', 'major'], 'safe'],
        ];
    }

    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['eula'] = [
            'class' => EulaBehavior::className(),
            'when' => ['name' => SettingEnum::EULA, 'major' => true],
        ];

        return $behaviors;
    }

    public function fields()
    {
        return ['name', 'value'];
    }

}
/**
 * @SWG\Definition(
 *     definition="Setting",
 *     type="object",
 *     description="Setting model",
 *     allOf={
 *       @SWG\Schema(ref="#/definitions/Setting"),
 *       @SWG\Schema(
 *         required={"name","value"},
 *         @SWG\Property(property="name", type="string", example="EULA", description="Setting name, readonly value, available: 'EULA'"),
 *         @SWG\Property(property="value", type="string", example="<h1>End-user license agreement</h1>", description="Setting value"),
 *         @SWG\Property(property="major", type="boolean", example=true, description="Are the changes major or not, default value is false")
 *       )
 *     }
 * )
 */