255], [['trigger_ids'], 'each', 'rule' => ['integer']], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'type' => 'Тип', 'item_id' => 'Элемент', 'item_value' => 'Значение Элемента', 'trigger_ids' => 'Triggers', 'name' => 'Название', ]; } /** * @inheritdoc */ public function behaviors() { return [ [ 'class' => LinkerBehavior::className(), 'relations' => [ 'trigger_ids' => 'triggers', ], ], ]; } /** * @return array */ public static function getList() { return ArrayHelper::map(self::find()->all(), 'id', 'name'); } /** * @return array */ public static function getTypes() { return [ self::TYPE_ITEM_VALUE => 'Изменить значение Элемента', ]; } /** * @return string */ public function getTypeLabel() { return self::getTypes()[$this->type]; } /** * @return \yii\db\ActiveQuery */ public function getTriggers() { return $this->hasMany(Trigger::className(), ['id' => 'trigger_id']) ->viaTable('trigger_task', ['task_id' => 'id']); } /** * @return \yii\db\ActiveQuery */ public function getItem() { return $this->hasOne(Item::className(), ['id' => 'item_id']); } }