Blame view

common/models/Road.php 2.47 KB
b41d5459   Yarik   first commit
1
2
3
4
5
6
7
8
9
10
11
12
  <?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
b41d5459   Yarik   first commit
13
14
   * @property integer $index
   *
b41d5459   Yarik   first commit
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
   * @property RoadType $roadType
   * @property RoadPassport[] $roadPassports
   */
  class Road extends \yii\db\ActiveRecord
  {
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'road';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
a1e5908c   Yarik   Yarik
34
35
              [['road_type_id', 'name', 'index'], 'required'],
              [['road_type_id', 'index'], 'integer'],
b41d5459   Yarik   first commit
36
37
38
              [['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.'],
b41d5459   Yarik   first commit
39
40
41
42
43
44
45
46
47
48
49
50
51
              [['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' => 'Тип дороги',
b41d5459   Yarik   first commit
52
53
54
55
56
57
58
              'index' => 'Індекс дороги',
          ];
      }
  
      /**
       * @return \yii\db\ActiveQuery
       */
b41d5459   Yarik   first commit
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
      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');
      }
  }