Completed
Push — master ( c22208...64acfb )
by Igor
04:17
created

Region::getCountry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use app\models\query\RegionQuery;
7
8
/**
9
 * This is the model class for table "region".
10
 *
11
 * @property integer $region_id
12
 * @property integer $country_id
13
 * @property string $title
14
 *
15
 * @property City[] $city
16
 * @property Country $country
17
 */
18
class Region extends \yii\db\ActiveRecord
19
{
20
    /**
21
     * @inheritdoc
22
     */
23
    public static function tableName()
24
    {
25
        return 'region';
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function rules()
32
    {
33
        return [
34
            ['country_id', 'required'],
35
            ['country_id', 'integer'],
36
37
            ['title', 'string', 'max' => 150],
38
            ['title', 'required']
39
        ];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function attributeLabels()
46
    {
47
        return [
48
            'region_id' => Yii::t('app', 'Region'),
49
            'country_id' => Yii::t('app', 'Country'),
50
            'title' => Yii::t('app', 'Title'),
51
        ];
52
    }
53
54
    /**
55
     * @return \yii\db\ActiveQuery
56
     */
57
    public function getCountry()
58
    {
59
        return $this->hasOne(Country::className(), ['country_id' => 'country_id']);
60
    }
61
62
    /**
63
     * @inheritdoc
64
     * @return RegionQuery
65
     */
66
    public static function find()
67
    {
68
        return new RegionQuery(get_called_class());
69
    }
70
}
71