1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace app\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use Itstructure\AdminModule\models\{Language, ActiveRecord}; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the model class for table "qualities_language". |
10
|
|
|
* |
11
|
|
|
* @property int $qualities_id |
12
|
|
|
* @property int $language_id |
13
|
|
|
* @property string $title |
14
|
|
|
* @property string $description |
15
|
|
|
* @property string $created_at |
16
|
|
|
* @property string $updated_at |
17
|
|
|
* |
18
|
|
|
* @property Language $language |
19
|
|
|
* @property Quality $qualities |
20
|
|
|
*/ |
21
|
|
|
class QualityLanguage extends ActiveRecord |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public static function tableName() |
27
|
|
|
{ |
28
|
|
|
return 'qualities_language'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
|
|
public function rules() |
35
|
|
|
{ |
36
|
|
|
return [ |
37
|
|
|
[ |
38
|
|
|
[ |
39
|
|
|
'qualities_id', |
40
|
|
|
'language_id', |
41
|
|
|
], |
42
|
|
|
'required' |
43
|
|
|
], |
44
|
|
|
[ |
45
|
|
|
[ |
46
|
|
|
'qualities_id', |
47
|
|
|
'language_id' |
48
|
|
|
], |
49
|
|
|
'integer' |
50
|
|
|
], |
51
|
|
|
[ |
52
|
|
|
[ |
53
|
|
|
'created_at', |
54
|
|
|
'updated_at' |
55
|
|
|
], |
56
|
|
|
'safe' |
57
|
|
|
], |
58
|
|
|
[ |
59
|
|
|
[ |
60
|
|
|
'title' |
61
|
|
|
], |
62
|
|
|
'string', |
63
|
|
|
'max' => 128 |
64
|
|
|
], |
65
|
|
|
[ |
66
|
|
|
[ |
67
|
|
|
'description' |
68
|
|
|
], |
69
|
|
|
'string', |
70
|
|
|
'max' => 1024 |
71
|
|
|
], |
72
|
|
|
[ |
73
|
|
|
[ |
74
|
|
|
'qualities_id', |
75
|
|
|
'language_id' |
76
|
|
|
], |
77
|
|
|
'unique', |
78
|
|
|
'targetAttribute' => [ |
79
|
|
|
'qualities_id', |
80
|
|
|
'language_id' |
81
|
|
|
] |
82
|
|
|
], |
83
|
|
|
[ |
84
|
|
|
[ |
85
|
|
|
'language_id' |
86
|
|
|
], |
87
|
|
|
'exist', |
88
|
|
|
'skipOnError' => true, |
89
|
|
|
'targetClass' => Language::class, |
90
|
|
|
'targetAttribute' => [ |
91
|
|
|
'language_id' => 'id' |
92
|
|
|
] |
93
|
|
|
], |
94
|
|
|
[ |
95
|
|
|
[ |
96
|
|
|
'qualities_id' |
97
|
|
|
], |
98
|
|
|
'exist', |
99
|
|
|
'skipOnError' => true, |
100
|
|
|
'targetClass' => Quality::class, |
101
|
|
|
'targetAttribute' => [ |
102
|
|
|
'qualities_id' => 'id' |
103
|
|
|
] |
104
|
|
|
], |
105
|
|
|
]; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* {@inheritdoc} |
110
|
|
|
*/ |
111
|
|
View Code Duplication |
public function attributeLabels() |
|
|
|
|
112
|
|
|
{ |
113
|
|
|
return [ |
114
|
|
|
'qualities_id' => 'Qualities ID', |
115
|
|
|
'language_id' => 'Language ID', |
116
|
|
|
'title' => Yii::t('app', 'Title'), |
117
|
|
|
'description' => Yii::t('app', 'Description'), |
118
|
|
|
'created_at' => Yii::t('app', 'Created date'), |
119
|
|
|
'updated_at' => Yii::t('app', 'Updated date'), |
120
|
|
|
]; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return \yii\db\ActiveQuery |
125
|
|
|
*/ |
126
|
|
|
public function getLanguage() |
127
|
|
|
{ |
128
|
|
|
return $this->hasOne(Language::class, [ |
129
|
|
|
'id' => 'language_id' |
130
|
|
|
]); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @return \yii\db\ActiveQuery |
135
|
|
|
*/ |
136
|
|
|
public function getQualities() |
137
|
|
|
{ |
138
|
|
|
return $this->hasOne(Quality::class, [ |
139
|
|
|
'id' => 'qualities_id' |
140
|
|
|
]); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.