OSDN Git Service

Изменение импорта
[invent/invent.git] / models / Status.php
1 <?php
2
3 namespace app\models;
4
5 use Yii;
6
7 /**
8  * This is the model class for table "{{%status}}".
9  *
10  * @property int    $id   Номер по порядку
11  * @property string $name Состояние
12  *
13  * @property Items[] $items
14  */
15 class Status extends \yii\db\ActiveRecord
16 {
17     /**
18      * {@inheritdoc}
19      */
20     public static function tableName()
21     {
22         return '{{%status}}';
23     }
24
25     /**
26      * {@inheritdoc}
27      */
28     public function rules()
29     {
30         return [
31             [['name'], 'required'],
32             [['name'], 'string', 'max' => 100],
33             [['name'], 'unique'],
34         ];
35     }
36
37     /**
38      * {@inheritdoc}
39      */
40     public function attributeLabels()
41     {
42         return [
43             'id'   => Yii::t('app', 'Identify'),
44             'name' => Yii::t('status', 'Status name'),
45         ];
46     }
47
48     /**
49      * Получение данных из связанной тблицы оборудования.
50      *
51      * @return \yii\db\ActiveQuery
52      */
53     public function getMoving()
54     {
55         return $this->hasMany(Noving::className(), [ 'state_id' => 'id' ]);
56     }
57     public function getItems()
58     {
59         return $this->getMoving()->select(Items::tableName() . '.*')->joinWith('items');
60     }
61 }