1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace nkostadinov\taxonomy\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use yii\base\Model; |
7
|
|
|
use yii\data\ActiveDataProvider; |
8
|
|
|
use nkostadinov\taxonomy\models\TaxonomyDef; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* TaxonomyDefSearch represents the model behind the search form about `nkostadinov\taxonomy\models\TaxonomyDef`. |
12
|
|
|
*/ |
13
|
|
|
class TaxonomyDefSearch extends TaxonomyDef |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @inheritdoc |
17
|
|
|
*/ |
18
|
|
|
public function rules() |
19
|
|
|
{ |
20
|
|
|
return [ |
21
|
|
|
[['id', 'total_count'], 'integer'], |
22
|
|
|
[['name', 'class', 'created_at', 'data_table', 'ref_table'], '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 = TaxonomyDef::find(); |
45
|
|
|
|
46
|
|
|
$dataProvider = new ActiveDataProvider([ |
47
|
|
|
'query' => $query, |
48
|
|
|
]); |
49
|
|
|
|
50
|
|
|
$this->load($params); |
51
|
|
|
|
52
|
|
|
if (!$this->validate()) { |
53
|
|
|
// uncomment the following line if you do not want to any records when validation fails |
54
|
|
|
// $query->where('0=1'); |
55
|
|
|
return $dataProvider; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$query->andFilterWhere([ |
59
|
|
|
'id' => $this->id, |
60
|
|
|
'created_at' => $this->created_at, |
61
|
|
|
'total_count' => $this->total_count, |
62
|
|
|
]); |
63
|
|
|
|
64
|
|
|
$query->andFilterWhere(['like', 'name', $this->name]) |
65
|
|
|
->andFilterWhere(['like', 'class', $this->class]) |
66
|
|
|
->andFilterWhere(['like', 'data_table', $this->data_table]) |
|
|
|
|
67
|
|
|
->andFilterWhere(['like', 'ref_table', $this->ref_table]); |
|
|
|
|
68
|
|
|
|
69
|
|
|
return $dataProvider; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.