/** * User getter * @return app\modules\user\common\models\User */ public function getUser() { if ($this->_user === false) { $this->_user = User::findByEmail($this->email); } return $this->_user; }
/** * User role assignment * @param string $email User email * @return void */ public function actionAssign($email) { //user $user = User::findByEmail($email); if ($user === null) { return Json::encode(['error' => Yii::t('user', 'User not found.')]); } $model = new RoleForm(['users' => [$user->id]]); return Json::encode(['content' => $this->renderPartial('form/assignment', ['model' => $model])]); }