Road.php
3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "road".
*
* @property integer $road_id
* @property string $name
* @property integer $road_type_id
* @property integer $road_category_id
* @property integer $index
*
* @property RoadCategory $roadCategory
* @property RoadType $roadType
* @property RoadPassport[] $roadPassports
*/
class Road extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'road';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['road_type_id', 'road_category_id', 'name', 'index'], 'required'],
[['road_type_id', 'road_category_id', 'index'], 'integer'],
[['index'], 'default', 'value' => 0],
[['name'], 'string', 'max' => 255],
[['road_type_id', 'index'], 'unique', 'skipOnError' => true, 'targetAttribute' => ['road_type_id', 'index'], 'message' => 'The combination of Road Type ID and Index has already been taken.'],
[['road_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => RoadCategory::className(), 'targetAttribute' => ['road_category_id' => 'road_category_id']],
[['road_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => RoadType::className(), 'targetAttribute' => ['road_type_id' => 'road_type_id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'road_id' => 'Road ID',
'name' => 'Назва дороги',
'road_type_id' => 'Тип дороги',
'road_category_id' => 'Категорія дороги',
'index' => 'Індекс дороги',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRoadCategory()
{
return $this->hasOne(RoadCategory::className(), ['road_category_id' => 'road_category_id'])->inverseOf('roads');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRoadType()
{
return $this->hasOne(RoadType::className(), ['road_type_id' => 'road_type_id'])->inverseOf('roads');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRoadPassports()
{
return $this->hasMany(RoadPassport::className(), ['road_id' => 'road_id'])->inverseOf('road');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRoadServices()
{
return $this->hasMany(RoadService::className(), [ 'road_id' => 'road_id' ])
->inverseOf('road');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSettlementAddressLinks()
{
return $this->hasOne(SettlementAddressLink::className(), ['road_id' => 'road_id'])->inverseOf('road');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getFlowIntensities()
{
return $this->hasOne(FlowIntensity::className(), [ 'road_id' => 'road_id' ])
->inverseOf('road');
}
}