Passed
Pull Request — master (#2)
by
unknown
15:51
created

ContactLanguage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 132
c 0
b 0
f 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getContacts() 0 4 1
A getLanguage() 0 4 1
A attributeLabels() 0 13 1
A rules() 0 79 1
A tableName() 0 3 1
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 "contacts_language".
10
 *
11
 * @property int $contacts_id
12
 * @property int $language_id
13
 * @property string $title
14
 * @property string $address
15
 * @property string $email
16
 * @property string $phone
17
 * @property string $metaKeys
18
 * @property string $metaDescription
19
 * @property string $created_at
20
 * @property string $updated_at
21
 *
22
 * @property Contact $contacts
23
 * @property Language $language
24
 *
25
 * @package app\models
26
 */
27
class ContactLanguage extends ActiveRecord
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public static function tableName()
33
    {
34
        return 'contacts_language';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function rules()
41
    {
42
        return [
43
            [
44
                [
45
                    'contacts_id',
46
                    'language_id'
47
                ],
48
                'required'
49
            ],
50
            [
51
                [
52
                    'contacts_id',
53
                    'language_id'
54
                ],
55
                'integer'
56
            ],
57
            [
58
                [
59
                    'created_at',
60
                    'updated_at'
61
                ],
62
                'safe'
63
            ],
64
            [
65
                [
66
                    'title',
67
                    'metaKeys',
68
                    'metaDescription'
69
                ],
70
                'string',
71
                'max' => 255
72
            ],
73
            [
74
                [
75
                    'address'
76
                ],
77
                'string',
78
                'max' => 128
79
            ],
80
            [
81
                [
82
                    'email'
83
                ],
84
                'string',
85
                'max' => 128
86
            ],
87
            [
88
                [
89
                    'phone'
90
                ],
91
                'string',
92
                'max' => 128
93
            ],
94
            [
95
                [
96
                    'contacts_id',
97
                    'language_id'
98
                ],
99
                'unique',
100
                'targetAttribute' => ['contacts_id', 'language_id']
101
            ],
102
            [
103
                [
104
                    'contacts_id'
105
                ],
106
                'exist',
107
                'skipOnError' => true,
108
                'targetClass' => Contact::class,
109
                'targetAttribute' => ['contacts_id' => 'id']
110
            ],
111
            [
112
                [
113
                    'language_id'
114
                ],
115
                'exist',
116
                'skipOnError' => true,
117
                'targetClass' => Language::class,
118
                'targetAttribute' => ['language_id' => 'id']
119
            ],
120
        ];
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126
    public function attributeLabels()
127
    {
128
        return [
129
            'contacts_id' => 'Contacts ID',
130
            'language_id' => 'Language ID',
131
            'title' => Yii::t('contacts', 'Title'),
132
            'address' => Yii::t('contacts', 'Address'),
133
            'email' => Yii::t('contacts', 'Email'),
134
            'phone' => Yii::t('contacts', 'Phone'),
135
            'metaKeys' => Yii::t('app', 'Meta keys'),
136
            'metaDescription' => Yii::t('app', 'Meta description'),
137
            'created_at' => Yii::t('app', 'Created date'),
138
            'updated_at' => Yii::t('app', 'Updated date'),
139
        ];
140
    }
141
142
    /**
143
     * @return \yii\db\ActiveQuery
144
     */
145
    public function getContacts()
146
    {
147
        return $this->hasOne(Contact::class, [
148
            'id' => 'contacts_id'
149
        ]);
150
    }
151
152
    /**
153
     * @return \yii\db\ActiveQuery
154
     */
155
    public function getLanguage()
156
    {
157
        return $this->hasOne(Language::class, [
158
            'id' => 'language_id'
159
        ]);
160
    }
161
}
162