OSDN Git Service

2e9102286dd4d655aae58452313e50202fcd9b6f
[invent/invent.git] / models / Types.php
1 <?php
2
3 namespace app\models;
4
5 use Yii;
6
7 /**
8  * This is the model class for table "{{%types}}".
9  *
10  * @property int $id Идентификатор типа (неизменяемое)
11  * @property string|null $name Тип оборудования
12  *
13  * @property Items[] $items
14  */
15 class Types extends \yii\db\ActiveRecord
16 {
17     /**
18      * {@inheritdoc}
19      */
20     public static function tableName()
21     {
22         return '{{%types}}';
23     }
24
25     /**
26      * {@inheritdoc}
27      */
28     public function rules()
29     {
30         return [
31             [['name'], 'string', 'max' => 20],
32         ];
33     }
34
35     /**
36      * {@inheritdoc}
37      */
38     public function attributeLabels()
39     {
40         return [
41             'id' => Yii::t('app', 'Идентификатор типа (неизменяемое)'),
42             'name' => Yii::t('app', 'Тип оборудования'),
43         ];
44     }
45
46     /**
47      * Gets query for [[Items]].
48      *
49      * @return \yii\db\ActiveQuery
50      */
51     public function getItems()
52     {
53         return $this->hasMany(Items::className(), ['type_id' => 'id']);
54     }
55 }