Skip to content

Commit 68abc25

Browse files
committed
用户搜索bug
1 parent 245131e commit 68abc25

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

models/searchs/User.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public function scenarios()
4040
public function search($params)
4141
{
4242
$query = UserModel::find();
43-
$this->load($params);
43+
$this->setAttributes($params);
44+
$status = $this->status ?: parent::STATUS_ACTIVE;
4445
$query->andFilterWhere([
4546
'id' => $this->id,
46-
'status' => $this->status,
4747
'created_at' => $this->created_at,
4848
'updated_at' => $this->updated_at,
4949
]);
@@ -56,12 +56,9 @@ public function search($params)
5656
"status",
5757
"created_at",
5858
]);
59-
$query->andFilterWhere(['like', 'username', $this->username])
60-
->andFilterWhere(['like', 'auth_key', $this->auth_key])
61-
->andFilterWhere(['like', 'password_hash', $this->password_hash])
62-
->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])
63-
->andFilterWhere(['like', 'email', $this->email]);
64-
$query->andWhere(['status' => parent::STATUS_ACTIVE]);
59+
$query->andFilterWhere(['like', 'username', $this->username]);
60+
$query->andFilterWhere(['like', 'email', $this->email]);
61+
$query->andFilterWhere(['status' => $status]);
6562
$query->orderBy(['id' => 'asc']);
6663
$result = $query->asArray()->all();
6764
foreach ($result as $key => $value) {

0 commit comments

Comments
 (0)