|
1
|
|
|
<?php |
|
2
|
|
|
namespace andmemasin\language\models; |
|
3
|
|
|
|
|
4
|
|
|
use yii\base\Model; |
|
5
|
|
|
use yii\data\ActiveDataProvider; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* LanguageSearch represents the model behind the search form about `andmemasin\language\models\Language`. |
|
9
|
|
|
* @package andmemasin\language\models |
|
10
|
|
|
* @author Tonis Ormisson <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class LanguageSearch extends Language |
|
13
|
|
|
{ |
|
14
|
|
|
public $isSearchModel = true; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* {@inheritdoc} |
|
18
|
|
|
*/ |
|
19
|
|
|
public function rules() |
|
20
|
|
|
{ |
|
21
|
|
|
return [ |
|
22
|
|
|
[['language_id','language', 'name', 'native_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 = Language::find(); |
|
45
|
|
|
|
|
46
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
47
|
|
|
'query' => $query, |
|
48
|
|
|
'sort'=> ['defaultOrder' => [self::primaryKey()[0]=>SORT_DESC]] |
|
49
|
|
|
]); |
|
50
|
|
|
|
|
51
|
|
|
$this->load($params); |
|
52
|
|
|
|
|
53
|
|
|
if (!$this->validate()) { |
|
54
|
|
|
return $dataProvider; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
// grid filtering conditions |
|
58
|
|
|
$query->andFilterWhere([ |
|
59
|
|
|
'language_id' => $this->language_id, |
|
60
|
|
|
]); |
|
61
|
|
|
$query->andFilterWhere(['like', 'language', $this->language]) |
|
62
|
|
|
->andFilterWhere(['like', 'name', $this->name]) |
|
63
|
|
|
->andFilterWhere(['like', 'native_name', $this->native_name]) |
|
64
|
|
|
; |
|
65
|
|
|
|
|
66
|
|
|
return $dataProvider; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|