Skip to content

Commit

Permalink
用户搜索bug
Browse files Browse the repository at this point in the history
  • Loading branch information
windhoney committed Apr 19, 2019
1 parent 245131e commit 68abc25
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions models/searchs/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function scenarios()
public function search($params)
{
$query = UserModel::find();
$this->load($params);
$this->setAttributes($params);
$status = $this->status ?: parent::STATUS_ACTIVE;
$query->andFilterWhere([
'id' => $this->id,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
Expand All @@ -56,12 +56,9 @@ public function search($params)
"status",
"created_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]);
$query->andWhere(['status' => parent::STATUS_ACTIVE]);
$query->andFilterWhere(['like', 'username', $this->username]);
$query->andFilterWhere(['like', 'email', $this->email]);
$query->andFilterWhere(['status' => $status]);
$query->orderBy(['id' => 'asc']);
$result = $query->asArray()->all();
foreach ($result as $key => $value) {
Expand Down

0 comments on commit 68abc25

Please sign in to comment.