OSDN Git Service

Исправление багов при импорте. Внесена корректива в PHPExcel, так как неправильная...
[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 int         $ccount Количество проинвентаризированных предметов/оборудования для конкретного типа
14  * @property string|null $tname  Наименование типа оборудования
15  *
16  * @property Items[]     $items
17  */
18 class Types extends \yii\db\ActiveRecord
19 {
20     public $icount;
21     public $tname;
22     public $ccount;
23     /**
24      * {@inheritdoc}
25      */
26     public static function tableName()
27     {
28         return '{{%types}}';
29     }
30
31     /**
32      * {@inheritdoc}
33      */
34     public function rules()
35     {
36         return [
37             [[ 'id' ], 'integer' ],
38             [[ 'name' ], 'string', 'max' => 100 ],
39         ];
40     }
41
42     /**
43      * {@inheritdoc}
44      */
45     public function attributeLabels()
46     {
47         return [
48             'id'     => Yii::t('app',   'Identifire'),
49             'name'   => Yii::t('types', 'Type'),
50             'tname'  => Yii::t('types', 'Types'),
51             'icount' => Yii::t('items', 'Total items count'),
52             'ccount' => Yii::t('items', 'Total items checked')
53         ];
54     }
55
56     /**
57      * Gets query for [[Items]].
58      *
59      * @return \yii\db\ActiveQuery
60      */
61     public function getModels()
62     {
63         return $this->hasMany(Models::className(), [ 'type_id' => 'id' ]);
64     }
65
66     public function getItems()
67     {
68         return $this->getModels()->select(Items::tableName() . '.*')->joinWith('items');
69     }
70 }