255], [['room_id'], 'exist', 'skipOnError' => true, 'targetClass' => Room::className(), 'targetAttribute' => ['room_id' => 'id']], [['board_id'], 'exist', 'skipOnError' => true, 'targetClass' => Board::className(), 'targetAttribute' => ['board_id' => 'id']], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('app', 'ID'), 'type' => Yii::t('app', 'Тип'), 'update_interval' => Yii::t('app', 'Интервал обновления'), 'save_history_interval' => Yii::t('app', 'Интервал сохранения в историю'), 'room_id' => Yii::t('app', 'Комната'), 'board_id' => Yii::t('app', 'Плата'), 'url' => Yii::t('app', 'Url'), 'name' => Yii::t('app', 'Название'), 'icon' => Yii::t('app', 'Иконка'), 'bg' => Yii::t('app', 'Фон'), 'class' => Yii::t('app', 'Класс'), 'sort_order' => Yii::t('app', 'Порядок сортировки'), ]; } /** * @return \yii\db\ActiveQuery */ public function getHistories() { return $this->hasMany(History::className(), ['item_id' => 'id'])->inverseOf('item'); } /** * @return \yii\db\ActiveQuery */ public function getRoom() { return $this->hasOne(Room::className(), ['id' => 'room_id'])->inverseOf('items'); } /** * @return \yii\db\ActiveQuery */ public function getBoard() { return $this->hasOne(Board::className(), ['id' => 'board_id'])->inverseOf('items'); } /** * @inheritdoc * @return ItemQuery the active query used by this AR class. */ public static function find() { return new ItemQuery(get_called_class()); } public static function getTypesArray() { return [ self::TYPE_SWITCH => 'Переключатель', self::TYPE_VARIABLE => 'Переменная', self::TYPE_VARIABLE_BOOLEAN => 'Переменная булев', self::TYPE_VARIABLE_BOOLEAN_DOOR => 'Переменная булев дверь', ]; } }