ddebd16b
Yarik
test
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Project;
/**
* ProjectSearch represents the model behind the search form about `common\models\Project`.
*/
class ProjectSearch extends Project
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[
[
'project_id',
|
ddebd16b
Yarik
test
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
'project_pid',
'user_add_id',
'payment_variant',
'deadline',
'contractual',
],
'integer',
],
[
[
'name',
'link',
'date_add',
'date_end',
'budget',
'city',
'street',
'house',
'description',
'file',
'specializationString',
],
'safe',
],
[
[ 'view_count' ],
'number',
],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Project::find();
// add conditions that should always apply here
$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;
}
|
4c9663e0
Yarik
test
|
90
91
92
93
94
95
96
97
98
99
100
101
102
|
$query2 = [ ];
if(!empty( $this->specializationString )) {
$query2 = Project::find()
->select([ 'project.project_id' ], 'DISTINCT')
->joinWith([ 'specializations' ])
->where([
'like',
'specialization_name',
$this->specializationString,
])
->asArray()
->column();
}
|
ddebd16b
Yarik
test
|
103
|
|
a02e2fdb
Yarik
test
|
104
105
|
$query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]);
|
ddebd16b
Yarik
test
|
106
107
108
|
// grid filtering conditions
$query->andFilterWhere([
'project_id' => $this->project_id,
|
ddebd16b
Yarik
test
|
109
110
111
112
113
114
115
116
117
118
|
'project_pid' => $this->project_pid,
'date_add' => $this->date_add,
'date_end' => $this->date_end,
'user_add_id' => $this->user_add_id,
'view_count' => $this->view_count,
'payment_variant' => $this->payment_variant,
'deadline' => $this->deadline,
'contractual' => $this->contractual,
]);
|
4c9663e0
Yarik
test
|
119
120
121
122
123
124
|
$query->andFilterWhere(
[
'project_id' => $query2,
]
);
|
ddebd16b
Yarik
test
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
$query->andFilterWhere([
'like',
'name',
$this->name,
])
->andFilterWhere([
'like',
'link',
$this->link,
])
->andFilterWhere([
'like',
'budget',
$this->budget,
])
->andFilterWhere([
'like',
'city',
$this->city,
])
->andFilterWhere([
'like',
'street',
$this->street,
])
->andFilterWhere([
'like',
'house',
$this->house,
])
->andFilterWhere([
'like',
'description',
$this->description,
])
->andFilterWhere([
'like',
'file',
$this->file,
|
ddebd16b
Yarik
test
|
164
165
166
167
168
|
]);
return $dataProvider;
}
}
|