/** * @return Auth|static */ public function getUser() { if ($this->user === null) { $this->user = Auth::findOne(['login' => $this->login, 'blocked' => Auth::BLOCKED_NO]); } return $this->user; }
/** * Finds the Auth model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Auth the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Auth::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @param string $login * @return mixed * @throws \yii\base\InvalidConfigException */ private function getUserId($login) { /* @var $model \app\modules\auth\models\Auth */ $model = Auth::findOne(['login' => $login]); if ($model === null) { throw new InvalidConfigException(Yii::t('auth', 'The user login is not found')); } return $model->id; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Auth::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'blocked' => $this->blocked]); $query->andFilterWhere(['like', 'login', $this->login])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }