/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/kdf/KUserParam.php
107 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\kdf; use common\kdf\base\BaseKdf; use common\models\gtp\User; use common\models\UserParam; use Yii; use yii\base\InvalidConfigException; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * Классификактор - параметры пользователя * * @property string $title Title * @property string $code code * @property int $type_id Type * @property string $default_value Default value * * @property KType $type * @property UserParam[] $userParams * @property User[] $users * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2019-2020 */ class KUserParam extends BaseKdf { const HIDE_TMS = 1; // язык отображения сайта const LANGUAGE = 2; /** * {@inheritdoc} */ public static function tableName() { return 'k_user_param'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['type_id'], 'default', 'value' => KType::TBOOLEAN], [['title', 'code', 'type_id'], 'required'], [['type_id'], 'integer'], [['title', 'code', 'default_value'], 'string', 'max' => 255], [['code'], 'unique'], [ ['type_id'], 'exist', 'skipOnError' => true, 'targetClass' => KType::class, 'targetAttribute' => ['type_id' => 'id'] ], ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'title' => Yii::t('app', 'Title'), 'code' => Yii::t('app', 'code'), 'type_id' => Yii::t('app', 'Type'), 'default_value' => Yii::t('app', 'Default value'), ]); } /** * Gets query for [[Type]]. * * @return ActiveQuery */ public function getType() { return $this->hasOne(KType::class, ['id' => 'type_id']); } /** * Gets query for [[UserParams]]. * * @return ActiveQuery */ public function getUserParam() { return $this->hasMany(UserParam::class, ['param_id' => 'id']); } /** * Gets query for [[Users]]. * * @return ActiveQuery * @throws InvalidConfigException */ public function getUser() { return $this->hasMany(User::class, ['id' => 'user_id']) ->viaTable(UserParam::tableName(), ['param_id' => 'id']); } }