Example #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, 'last_login_time' => $this->last_login_time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'delect' => $this->delect]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'zipcode', $this->zipcode])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'client_name', $this->client_name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'street', $this->street])->andFilterWhere(['like', 'time_zone', $this->time_zone])->andFilterWhere(['like', 'channels', $this->channels])->andFilterWhere(['like', 'register_ip', $this->register_ip])->andFilterWhere(['like', 'last_login_ip', $this->last_login_ip])->andFilterWhere(['like', 'avatar_img', $this->avatar_img])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'accessToken', $this->accessToken]);
     //伪删除, 返回status大于 1 的
     $query->andWhere(['<', 'delect', 1]);
     return $dataProvider;
 }
Example #2
0
 public function actionDelectAll()
 {
     $res = User::find()->asArray()->where(['>', 'delect', 0])->all();
     return $res;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }