| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- /**
- * Class AuthRole
- * @package app\modules\common\models
- * @property string $id
- * @property string $name
- * @property string $data
- * @property string $edit_data
- * @property string $describe
- * @property integer $status
- * @property string $created_at
- * @property string $updated_at
- */
- class SaasAuthRole extends ActiveRecord
- {
- const STATUS_NORMAL = 1; // 正常
- const STATUS_DISABLE = 0; // 禁用
- public static function tableName()
- {
- return '{{%saas_auth_role}}';
- }
- public function behaviors()
- {
- return [
- [
- // 自动更新创建和更新时间
- 'class' => TimestampBehavior::class,
- 'value' => date("Y-m-d H:i:s")
- ]
- ];
- }
- public function rules()
- {
- return [
- [['id', 'status'], 'integer'],
- [['name'], 'string', 'max' => 64],
- [['name', 'data'], 'required'],
- [['data', 'edit_data'], 'string'],
- [['describe'], 'string', 'max' => 255],
- [['create_at', 'update_at'], 'safe']
- ];
- }
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'name' => '角色名称',
- 'create_at' => '创建时间',
- 'update_at' => '更新时间',
- 'data' => '角色数据',
- 'edit_data' => '角色数据',
- 'describe' => '简介',
- 'status' => '状态'
- ];
- }
- /**
- * 获取管理员
- * @return \yii\db\ActiveQuery
- * @throws \yii\base\InvalidConfigException
- */
- public function getAdmins()
- {
- return $this->hasMany(Admin::class, ['id' => 'admin_id'])
- ->viaTable('{{%saas_admin_role}}', ['role_id' => 'id']);
- }
- }
|