Exemplo n.º 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;
 }
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function search($params)
 {
     $query = User::find()->where('status=0');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['Id' => 'userId']);
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['reportTo' => 'Id']);
 }