Completed
Branch master (f58c14)
by Andrey
07:50
created

AboutLanguage::tableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 4
loc 4
rs 10
c 0
b 0
f 0
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 "about_language".
10
 *
11
 * @property int $about_id
12
 * @property int $language_id
13
 * @property string $title
14
 * @property string $description
15
 * @property string $content
16
 * @property string $metaKeys
17
 * @property string $metaDescription
18
 * @property string $created_at
19
 * @property string $updated_at
20
 *
21
 * @property About $about
22
 * @property Language $language
23
 *
24
 * @package app\models
25
 */
26 View Code Duplication
class AboutLanguage extends ActiveRecord
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public static function tableName()
32
    {
33
        return 'about_language';
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function rules()
40
    {
41
        return [
42
            [
43
                [
44
                    'about_id',
45
                    'language_id',
46
                ],
47
                'required'
48
            ],
49
            [
50
                [
51
                    'about_id',
52
                    'language_id'
53
                ],
54
                'integer'
55
            ],
56
            [
57
                [
58
                    'description',
59
                    'content'
60
                ],
61
                'string'
62
            ],
63
            [
64
                [
65
                    'created_at',
66
                    'updated_at'
67
                ],
68
                'safe'
69
            ],
70
            [
71
                [
72
                    'title',
73
                    'metaKeys',
74
                    'metaDescription'
75
                ],
76
                'string',
77
                'max' => 255
78
            ],
79
            [
80
                [
81
                    'about_id',
82
                    'language_id'
83
                ],
84
                'unique',
85
                'targetAttribute' => ['about_id', 'language_id']
86
            ],
87
            [
88
                [
89
                    'about_id'
90
                ],
91
                'exist',
92
                'skipOnError' => true,
93
                'targetClass' => About::class,
94
                'targetAttribute' => ['about_id' => 'id']
95
            ],
96
            [
97
                [
98
                    'language_id'
99
                ],
100
                'exist',
101
                'skipOnError' => true,
102
                'targetClass' => Language::class,
103
                'targetAttribute' => ['language_id' => 'id']
104
            ],
105
        ];
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function attributeLabels()
112
    {
113
        return [
114
            'about_id' => 'About ID',
115
            'language_id' => 'Language ID',
116
            'title' => Yii::t('app', 'Title'),
117
            'description' => Yii::t('app', 'Description'),
118
            'content' => Yii::t('app', 'Content'),
119
            'metaKeys' => Yii::t('app', 'Meta keys'),
120
            'metaDescription' => Yii::t('app', 'Meta description'),
121
            'created_at' => Yii::t('app', 'Created date'),
122
            'updated_at' => Yii::t('app', 'Updated date'),
123
        ];
124
    }
125
126
    /**
127
     * @return \yii\db\ActiveQuery
128
     */
129
    public function getAbout()
130
    {
131
        return $this->hasOne(About::class, [
132
            'id' => 'about_id'
133
        ]);
134
    }
135
136
    /**
137
     * @return \yii\db\ActiveQuery
138
     */
139
    public function getLanguage()
140
    {
141
        return $this->hasOne(Language::class, [
142
            'id' => 'language_id'
143
        ]);
144
    }
145
}
146