|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link http://www.writesdown.com/ |
|
4
|
|
|
* @copyright Copyright (c) 2015 WritesDown |
|
5
|
|
|
* @license http://www.writesdown.com/license/ |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace common\models; |
|
9
|
|
|
|
|
10
|
|
|
use Yii; |
|
11
|
|
|
use yii\db\ActiveRecord; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* This is the model class for table "{{%media_meta}}". |
|
15
|
|
|
* |
|
16
|
|
|
* @property integer $id |
|
17
|
|
|
* @property integer $media_id |
|
18
|
|
|
* @property string $name |
|
19
|
|
|
* @property string $value |
|
20
|
|
|
* |
|
21
|
|
|
* @property Media $media |
|
22
|
|
|
* |
|
23
|
|
|
* @author Agiel K. Saputra <[email protected]> |
|
24
|
|
|
* @since 0.1.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
class MediaMeta extends ActiveRecord |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @inheritdoc |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function tableName() |
|
32
|
|
|
{ |
|
33
|
|
|
return '{{%media_meta}}'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @inheritdoc |
|
38
|
|
|
*/ |
|
39
|
|
|
public function rules() |
|
40
|
|
|
{ |
|
41
|
|
|
return [ |
|
42
|
|
|
[['media_id', 'name', 'value'], 'required'], |
|
43
|
|
|
[['media_id'], 'integer'], |
|
44
|
|
|
[['value'], 'string'], |
|
45
|
|
|
[['name'], 'string', 'max' => 255], |
|
46
|
|
|
]; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @inheritdoc |
|
51
|
|
|
*/ |
|
52
|
|
View Code Duplication |
public function attributeLabels() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
|
|
'id' => Yii::t('writesdown', 'ID'), |
|
56
|
|
|
'media_id' => Yii::t('writesdown', 'Media ID'), |
|
57
|
|
|
'name' => Yii::t('writesdown', 'Meta Name'), |
|
58
|
|
|
'value' => Yii::t('writesdown', 'Meta Value'), |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return \yii\db\ActiveQuery |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getMedia() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->hasOne(Media::className(), ['id' => 'media_id']); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
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.