self::getTypesArray()], [['trig_item_value', 'name', 'trig_time', 'trig_time_wdays'], 'string', 'max' => 255], [['trig_time', 'trig_time_wdays', 'trig_date'], 'default', 'value' => null], [['task_ids'], 'each', 'rule' => ['integer']], [['active'], 'boolean'], [['active'], 'default', 'value' => true], ]; } /** * @inheritdoc */ public function behaviors() { return [ [ 'class' => LinkerBehavior::className(), 'relations' => [ 'task_ids' => 'tasks', ], ], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'active' => 'Включен', 'type' => 'Тип', 'trig_date' => 'Дата срабатывания', 'trig_time' => 'Время срабатывания', 'trig_time_wdays' => 'Дни срабатывания', 'trig_item_id' => 'Элемент срабатывания', 'trig_item_value' => 'Значение элемента срабатывания', 'task_ids' => 'Задачи', 'name' => 'Имя', ]; } /** * @return array */ public static function getTypes() { return [ self::TYPE_BY_ITEM_VALUE => 'Значение Элемента', self::TYPE_BY_USER_ITEM_CHANGE => 'Изменение Значение Элемента', self::TYPE_BY_DATE => 'Дата', self::TYPE_BY_TIME => 'Время', ]; } /** * @return array */ public static function getTypesArray() { return array_keys(self::getTypes()); } /** * @return string */ public function getTypeLabel() { return self::getTypes()[$this->type]; } /** * @return array */ public static function getList() { return ArrayHelper::map(self::find()->all(), 'id', 'name'); } /** * @return \yii\db\ActiveQuery */ public function getTasks() { return $this->hasMany(Task::className(), ['id' => 'task_id']) ->viaTable('trigger_task', ['trigger_id' => 'id']); } }