d55d2fe0
Yarik
Multilanguage
|
1
|
<?php
|
d55d2fe0
Yarik
Multilanguage
|
2
|
|
5c2eb7c8
Yarik
Big commit almost...
|
3
4
5
6
7
|
namespace common\modules\product\models;
use common\modules\language\models\Language;
use Yii;
use yii\db\ActiveRecord;
|
d55d2fe0
Yarik
Multilanguage
|
8
9
|
/**
|
5c2eb7c8
Yarik
Big commit almost...
|
10
|
* This is the model class for table "product_variant_lang".
|
4428da8c
Yarik
Almost all databa...
|
11
|
*
|
5c2eb7c8
Yarik
Big commit almost...
|
12
13
|
* @property integer $product_variant_id
* @property integer $language_id
|
8af13427
Yarik
For leha commit.
|
14
|
* @property string $title
|
5c2eb7c8
Yarik
Big commit almost...
|
15
16
|
* @property Language $language
* @property ProductVariant $productVariant
|
d55d2fe0
Yarik
Multilanguage
|
17
|
*/
|
5c2eb7c8
Yarik
Big commit almost...
|
18
|
class ProductVariantLang extends ActiveRecord
|
d55d2fe0
Yarik
Multilanguage
|
19
|
{
|
5c2eb7c8
Yarik
Big commit almost...
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
public static function primaryKey()
{
return [
'product_variant_id',
'language_id',
];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'product_variant_lang';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[
|
8af13427
Yarik
For leha commit.
|
44
|
[ 'title' ],
|
5c2eb7c8
Yarik
Big commit almost...
|
45
46
47
|
'required',
],
[
|
8af13427
Yarik
For leha commit.
|
48
|
[ 'title' ],
|
5c2eb7c8
Yarik
Big commit almost...
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
'string',
'max' => 255,
],
[
[
'product_variant_id',
'language_id',
],
'unique',
'targetAttribute' => [
'product_variant_id',
'language_id',
],
'message' => 'The combination of Product Variant ID and Language ID has already been taken.',
],
[
[ 'language_id' ],
'exist',
'skipOnError' => true,
'targetClass' => Language::className(),
|
8af13427
Yarik
For leha commit.
|
69
|
'targetAttribute' => [ 'language_id' => 'id' ],
|
5c2eb7c8
Yarik
Big commit almost...
|
70
71
72
73
74
75
|
],
[
[ 'product_variant_id' ],
'exist',
'skipOnError' => true,
'targetClass' => ProductVariant::className(),
|
4428da8c
Yarik
Almost all databa...
|
76
|
'targetAttribute' => [ 'product_variant_id' => 'id' ],
|
5c2eb7c8
Yarik
Big commit almost...
|
77
78
79
80
81
82
83
84
85
86
87
88
|
],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'product_variant_id' => Yii::t('app', 'Product Variant ID'),
'language_id' => Yii::t('app', 'Language ID'),
|
4428da8c
Yarik
Almost all databa...
|
89
|
'title' => Yii::t('app', 'Name'),
|
5c2eb7c8
Yarik
Big commit almost...
|
90
91
92
93
94
95
96
97
|
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLanguage()
{
|
8af13427
Yarik
For leha commit.
|
98
|
return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
|
5c2eb7c8
Yarik
Big commit almost...
|
99
100
101
102
103
104
105
|
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProductVariant()
{
|
4428da8c
Yarik
Almost all databa...
|
106
|
return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
|
5c2eb7c8
Yarik
Big commit almost...
|
107
|
}
|
d55d2fe0
Yarik
Multilanguage
|
108
|
}
|