Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_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;
 }
Exemplo n.º 2
0
 public function search($params)
 {
     $query = User::find()->joinWith(['authItem' => function ($query) {
         $query->joinWith('ruleName', true, 'LEFT JOIN');
     }], true, 'INNER JOIN');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->current->getPageSize()]]);
     $dataProvider->sort->attributes['status'] = ['asc' => ['user.status' => SORT_DESC], 'desc' => ['user.status' => SORT_ASC]];
     $dataProvider->sort->attributes['authItem.description'] = ['asc' => ['auth_item.description' => SORT_ASC], 'desc' => ['auth_item.description' => SORT_DESC], 'default' => SORT_ASC, 'label' => 'test'];
     $dataProvider->sort->attributes['authItem.ruleName.name'] = ['asc' => ['auth_rule.name' => SORT_ASC], 'desc' => ['auth_rule.name' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['user.status' => $this->status]);
     $query->andFilterWhere(['like', 'user.username', $this->username])->andFilterWhere(['like', 'user.email', $this->email])->andFilterWhere(['like', 'auth_item.description', $this->{'authItem.description'}])->andFilterWhere(['like', 'auth_rule.name', $this->{'authItem.ruleName.name'}]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchConnection($params)
 {
     $query = User::find()->where(['flag_login' => 1]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // echo "masuk";die();
         //     // uncomment the following line if you do not want to return any records when validation fails
         //     // $query->where('0=1');
         return $dataProvider;
     }
     return $dataProvider;
 }