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")
* )
* }
* )
*/