OSDN Git Service

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