1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace app\modules\option\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This is the model class for table "options". |
9
|
|
|
* |
10
|
|
|
* @property string $namespace |
11
|
|
|
* @property string $key |
12
|
|
|
* @property string $value |
13
|
|
|
* @property string $description |
14
|
|
|
* @property string $created_at |
15
|
|
|
* @property string $updated_at |
16
|
|
|
*/ |
17
|
|
|
class Option extends \yii\db\ActiveRecord |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @inheritdoc |
21
|
|
|
*/ |
22
|
61 |
|
public static function tableName() |
23
|
|
|
{ |
24
|
61 |
|
return 'options'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @inheritdoc |
29
|
|
|
*/ |
30
|
2 |
|
public function rules() |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
2 |
|
[['namespace', 'key'], 'required'], |
34
|
|
|
[['created_at', 'updated_at'], 'safe'], |
35
|
|
|
[['namespace', 'key', 'value', 'description'], 'string', 'max' => 255], |
36
|
|
|
[['namespace', 'key'], |
37
|
|
|
'unique', |
38
|
|
|
'targetAttribute' => ['namespace', 'key'], |
39
|
|
|
'message' => 'The combination of Namespace and Key has already been taken.', |
40
|
|
|
], |
41
|
|
|
]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
*/ |
47
|
6 |
View Code Duplication |
public function attributeLabels() |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
6 |
|
'namespace' => Yii::t('option', 'Namespace'), |
51
|
6 |
|
'key' => Yii::t('option', 'Key'), |
52
|
6 |
|
'value' => Yii::t('option', 'Value'), |
53
|
6 |
|
'description' => Yii::t('option', 'Description'), |
54
|
6 |
|
'created_at' => Yii::t('option', 'Created At'), |
55
|
6 |
|
'updated_at' => Yii::t('option', 'Updated At'), |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
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.