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

PositionLanguage::tableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
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 "positions_language".
10
 *
11
 * @property int $positions_id
12
 * @property int $language_id
13
 * @property string $name
14
 * @property string $created_at
15
 * @property string $updated_at
16
 *
17
 * @property Language $language
18
 * @property Position $positions
19
 */
20
class PositionLanguage extends ActiveRecord
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public static function tableName()
26
    {
27
        return 'positions_language';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function rules()
34
    {
35
        return [
36
            [
37
                [
38
                    'positions_id',
39
                    'language_id'
40
                ],
41
                'required'
42
            ],
43
            [
44
                [
45
                    'positions_id',
46
                    'language_id'
47
                ],
48
                'integer'
49
            ],
50
            [
51
                [
52
                    'created_at',
53
                    'updated_at'
54
                ],
55
                'safe'
56
            ],
57
            [
58
                [
59
                    'name'
60
                ],
61
                'string',
62
                'max' => 64
63
            ],
64
            [
65
                [
66
                    'positions_id',
67
                    'language_id'
68
                ],
69
                'unique',
70
                'targetAttribute' => [
71
                    'positions_id',
72
                    'language_id'
73
                ]
74
            ],
75
            [
76
                [
77
                    'language_id'
78
                ],
79
                'exist',
80
                'skipOnError' => true,
81
                'targetClass' => Language::class,
82
                'targetAttribute' => [
83
                    'language_id' => 'id'
84
                ]
85
            ],
86
            [
87
                [
88
                    'positions_id'
89
                ],
90
                'exist',
91
                'skipOnError' => true,
92
                'targetClass' => Position::class,
93
                'targetAttribute' => [
94
                    'positions_id' => 'id'
95
                ]
96
            ],
97
        ];
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 View Code Duplication
    public function attributeLabels()
0 ignored issues
show
Duplication introduced by
This method 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...
104
    {
105
        return [
106
            'positions_id' => 'Positions ID',
107
            'language_id' => 'Language ID',
108
            'name' => Yii::t('positions', 'Name'),
109
            'created_at' => Yii::t('app', 'Created date'),
110
            'updated_at' => Yii::t('app', 'Updated date'),
111
        ];
112
    }
113
114
    /**
115
     * @return \yii\db\ActiveQuery
116
     */
117
    public function getLanguage()
118
    {
119
        return $this->hasOne(Language::class, [
120
            'id' => 'language_id'
121
        ]);
122
    }
123
124
    /**
125
     * @return \yii\db\ActiveQuery
126
     */
127
    public function getPositions()
128
    {
129
        return $this->hasOne(Position::class, [
130
            'id' => 'positions_id'
131
        ]);
132
    }
133
}
134