255], [['auth_key'], 'string', 'max' => 32], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'username' => Yii::t('common' ,'Username'), 'auth_key' => Yii::t('common' ,'Password'), 'password_hash' => 'Password Hash', 'password_reset_token' => 'Password Reset Token', 'email' => Yii::t('common' ,'Email'), 'mobile' => Yii::t('common' ,'Mobile'), 'role' => Yii::t('common' ,'Role'), 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } //获取所有用户 public function get_all_user(){ $user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll(); return $user; } public function getUsergrouplist() { /** * 第一个参数为要关联的字表模型类名称, *第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段 */ return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']); } public function getUsergroup() { /** * 第一个参数为要关联的字表模型类名称, *第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段 */ return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']); } /** * Generates password hash from password and sets it to the model * * @param string $password */ public function setPassword($password) { $this->password_hash = Yii::$app->security->generatePasswordHash($password); } /** * Generates "remember me" authentication key */ public function generateAuthKey() { $this->auth_key = Yii::$app->security->generateRandomString(); } }