/** * Find a user by [[username]] * * @return User|null */ public function getUser() { if ($this->_user === null) { $this->_user = User::findByUserName($this->username); } return $this->_user; }
/** * Creates a form model given a token. * * @param string $token * @param array $config name-value pairs that will be used to initialize the object properties * @throws \yii\base\InvalidParamException if token is empty or not valid */ public function __construct($token, $config = []) { if (empty($token) || !is_string($token)) { throw new InvalidParamException(Yii::t('cms', Yii::t('cms', 'Password reset token cannot be blank.'))); } $this->_user = User::findByPasswordResetToken($token); if (!$this->_user) { throw new InvalidParamException(Yii::t('cms', Yii::t('cms', 'Wrong password reset token.'))); } parent::__construct($config); }
/** * Returns the editor of this page. * * @return ActiveQueryInterface the relational query object. */ public function getEditor() { if ($this->updated_by == $this->created_by) { return $this->getAuthor(); } return $this->hasOne(User::className(), ['id' => 'updated_by']); }
/** * Renders a list of users. */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => User::find()]); return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $this->getModel()]); }