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

City::getFullLocation()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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