/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/AclRole.php
110 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\models; use common\interfaces\TitleInterface; use common\models\base\BaseModel; use common\traits\TitleRecordTrait; use Yii; use yii\base\InvalidConfigException; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * This is the model class for table "acl_role". * * @property string $title Title * @property string $code Code * * @property AclRoleRule[] $aclRoleRules * @property Acl[] $acls * @property AclRule[] $rules * @property User[] $users * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2020 */ class AclRole extends BaseModel implements TitleInterface { use TitleRecordTrait; const ADMIN_RW = 1; const ADMIN_RO = 2; CONST LINGUIST = 3; /** * {@inheritdoc} */ public static function tableName() { return 'acl_role'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['title', 'code'], 'required'], [['title', 'code'], 'string', 'max' => 100], [['code'], 'unique'], ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'title' => Yii::t('app', 'Title'), 'code' => Yii::t('app', 'Code'), ]); } /** * Gets query for [[AclRoleRules]]. * * @return ActiveQuery */ public function getAclRoleRule() { return $this->hasMany(AclRoleRule::class, ['role_id' => 'id']); } /** * Gets query for [[Acls]]. * * @return ActiveQuery */ public function getAcl() { return $this->hasMany(Acl::class, ['role_id' => 'id']); } /** * Gets query for [[Rules]]. * * @return ActiveQuery * @throws InvalidConfigException */ public function getRule() { return $this->hasMany(AclRule::class, ['id' => 'rule_id']) ->viaTable(AclRoleRule::tableName(), ['role_id' => 'id']); } /** * Gets query for [[Users]]. * * @return ActiveQuery * @throws InvalidConfigException */ public function getUser() { return $this->hasMany(User::class, ['id' => 'user_id']) ->viaTable(Acl::tableName(), ['role_id' => 'id']); } }