コード例 #1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
コード例 #2
0
 /**
  * Searches users.
  * @param array $params search query data
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['status' => $this->status])->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(updated_at), "%Y-%m-%d")', $this->updated_at]);
     return $dataProvider;
 }
コード例 #3
0
 public function install()
 {
     \app\config\ConfigManager::set(['components', 'user', 'identityClass'], User::className());
 }
コード例 #4
0
ファイル: Auth.php プロジェクト: bariew/yii2-user-cms-module
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return self::hasOne(User::className(), ['id' => 'user_id']);
 }
コード例 #5
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @param bool $search
  * @return User|UserSearch the loaded model
  * @throws NotFoundHttpException
  */
 protected function findModel($id, $search = false)
 {
     if ($search) {
         $model = new UserSearch();
     } elseif (!$id) {
         $model = new User();
     } elseif (!($model = User::findOne($id))) {
         throw new NotFoundHttpException(\Yii::t('modules/user', 'User not found'));
     }
     $model->scenario = 'root';
     return $model;
 }
コード例 #6
0
 public function down()
 {
     $this->dropTable(User::tableName());
 }