Example #1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = UserBackend::findByUsername($this->username);
     }
     return $this->_user;
 }
Example #2
0
 public function search($params)
 {
     $query = UserBackend::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => 'DESC']], 'pagination' => ['defaultPageSize' => 5]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     /*
     $dataProvider->query->joinWith([
         'parentGroup'=> function ($q){
             $q->from('tb_group tb_group2');  // join with tabel alias
         }
     ]);
          
     $query->andFilterWhere(['like', 'tb_group.name', $this->name]);
     $query->andFilterWhere(['like', 'tb_group2.name', $this->parent_id]);
     // SELESAI EDIT DISINI
     */
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'confirmed_at' => $this->confirmed_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Example #3
0
 protected function findModel($id)
 {
     if (($model = UserBackend::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }