d8c1a2e0
Yarik
Big commit artbox
|
1
|
<?php
|
d55d2fe0
Yarik
Multilanguage
|
2
|
|
6fdc7b5a
Yarik
Another one admin...
|
3
4
5
6
|
namespace common\modules\product\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
|
d55d2fe0
Yarik
Multilanguage
|
7
|
|
d8c1a2e0
Yarik
Big commit artbox
|
8
|
/**
|
6fdc7b5a
Yarik
Another one admin...
|
9
10
|
* ProductUnitSearch represents the model behind the search form about
* `common\modules\product\models\ProductUnit`.
|
d8c1a2e0
Yarik
Big commit artbox
|
11
|
*/
|
6fdc7b5a
Yarik
Another one admin...
|
12
|
class ProductUnitSearch extends ProductUnit
|
d8c1a2e0
Yarik
Big commit artbox
|
13
|
{
|
6fdc7b5a
Yarik
Another one admin...
|
14
|
|
c70f24ea
Yarik
For Leha commit.
|
15
|
public $title;
|
6fdc7b5a
Yarik
Another one admin...
|
16
17
18
19
20
21
22
23
24
25
|
public function behaviors()
{
return [];
}
public function attributeLabels()
{
$labels = parent::attributeLabels();
$new_labels = [
|
8af13427
Yarik
For leha commit.
|
26
|
'title' => \Yii::t('product', 'Product Unit Name'),
|
6fdc7b5a
Yarik
Another one admin...
|
27
28
29
30
31
32
33
34
35
36
37
|
];
return array_merge($labels, $new_labels);
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[
|
8af13427
Yarik
For leha commit.
|
38
|
[ 'title' ],
|
6fdc7b5a
Yarik
Another one admin...
|
39
40
41
|
'safe',
],
[
|
4428da8c
Yarik
Almost all databa...
|
42
|
[ 'id' ],
|
6fdc7b5a
Yarik
Another one admin...
|
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
|
'integer',
],
[
[ 'is_default' ],
'boolean',
],
];
}
/**
* @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)
{
|
5c2eb7c8
Yarik
Big commit almost...
|
70
71
|
$query = ProductUnit::find()
->joinWith('lang');
|
6fdc7b5a
Yarik
Another one admin...
|
72
73
74
|
// add conditions that should always apply here
|
4428da8c
Yarik
Almost all databa...
|
75
76
77
78
79
80
81
82
83
84
85
|
$dataProvider = new ActiveDataProvider(
[
'query' => $query,
'sort' => [
'attributes' => [
'id',
'is_defaut',
'title' => [
'asc' => [ 'product_unit_lang.title' => SORT_ASC ],
'desc' => [ 'product_unit_lang.title' => SORT_DESC ],
],
|
6fdc7b5a
Yarik
Another one admin...
|
86
87
|
],
],
|
4428da8c
Yarik
Almost all databa...
|
88
89
|
]
);
|
6fdc7b5a
Yarik
Another one admin...
|
90
91
92
|
$this->load($params);
|
4428da8c
Yarik
Almost all databa...
|
93
|
if (!$this->validate()) {
|
6fdc7b5a
Yarik
Another one admin...
|
94
95
96
97
98
99
|
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
|
4428da8c
Yarik
Almost all databa...
|
100
101
102
103
104
105
106
107
108
109
110
111
112
|
$query->andFilterWhere(
[
'id' => $this->id,
'is_default' => $this->is_default,
]
)
->andFilterWhere(
[
'ilike',
'product_unit_lang.title',
$this->title,
]
);
|
6fdc7b5a
Yarik
Another one admin...
|
113
|
|
d8c1a2e0
Yarik
Big commit artbox
|
114
115
|
return $dataProvider;
}
|
d8c1a2e0
Yarik
Big commit artbox
|
116
|
}
|