public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); $userRole = Yii::$app->authManager->getRole($this->role); Yii::$app->authManager->assign($userRole, $this->id); }