|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace modules\admin\models\search; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\base\Model; |
|
7
|
|
|
use yii\data\ActiveDataProvider; |
|
8
|
|
|
use modules\admin\models\User; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* UserSearch represents the model behind the search form of `modules\admin\models\User`. |
|
12
|
|
|
*/ |
|
13
|
|
|
class UserSearch extends User |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @inheritdoc |
|
17
|
|
|
*/ |
|
18
|
|
|
public function rules() |
|
19
|
|
|
{ |
|
20
|
|
|
return [ |
|
21
|
|
|
[['id', 'status', 'last_visit', 'created_at', 'updated_at', 'registration_type'], 'integer'], |
|
22
|
|
|
[['username', 'auth_key', 'password_hash', 'password_reset_token', 'email_confirm_token', 'email', 'first_name', 'last_name'], 'safe'], |
|
23
|
|
|
]; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @inheritdoc |
|
28
|
|
|
*/ |
|
29
|
|
|
public function scenarios() |
|
30
|
|
|
{ |
|
31
|
|
|
// bypass scenarios() implementation in the parent class |
|
32
|
|
|
return Model::scenarios(); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Creates data provider instance with search query applied |
|
37
|
|
|
* |
|
38
|
|
|
* @param array $params |
|
39
|
|
|
* |
|
40
|
|
|
* @return ActiveDataProvider |
|
41
|
|
|
*/ |
|
42
|
|
|
public function search($params) |
|
43
|
|
|
{ |
|
44
|
|
|
$query = User::find(); |
|
45
|
|
|
|
|
46
|
|
|
// add conditions that should always apply here |
|
47
|
|
|
|
|
48
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
49
|
|
|
'query' => $query, |
|
50
|
|
|
]); |
|
51
|
|
|
|
|
52
|
|
|
$this->load($params); |
|
53
|
|
|
|
|
54
|
|
|
if (!$this->validate()) { |
|
55
|
|
|
// uncomment the following line if you do not want to return any records when validation fails |
|
56
|
|
|
// $query->where('0=1'); |
|
|
|
|
|
|
57
|
|
|
return $dataProvider; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// grid filtering conditions |
|
61
|
|
|
$query->andFilterWhere([ |
|
62
|
|
|
'id' => $this->id, |
|
63
|
|
|
'status' => $this->status, |
|
64
|
|
|
'last_visit' => $this->last_visit, |
|
65
|
|
|
'created_at' => $this->created_at, |
|
66
|
|
|
'updated_at' => $this->updated_at, |
|
67
|
|
|
'registration_type' => $this->registration_type, |
|
68
|
|
|
]); |
|
69
|
|
|
|
|
70
|
|
|
$query->andFilterWhere(['like', 'username', $this->username]) |
|
71
|
|
|
->andFilterWhere(['like', 'auth_key', $this->auth_key]) |
|
72
|
|
|
->andFilterWhere(['like', 'password_hash', $this->password_hash]) |
|
73
|
|
|
->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token]) |
|
74
|
|
|
->andFilterWhere(['like', 'email_confirm_token', $this->email_confirm_token]) |
|
75
|
|
|
->andFilterWhere(['like', 'email', $this->email]) |
|
76
|
|
|
->andFilterWhere(['like', 'first_name', $this->first_name]) |
|
77
|
|
|
->andFilterWhere(['like', 'last_name', $this->last_name]); |
|
78
|
|
|
|
|
79
|
|
|
return $dataProvider; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|