255], [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'title' => 'Название', 'project_id' => 'Проект', 'created_at' => 'Дата создания', 'updated_at' => 'Дата редактирования', 'status' => 'Статус', 'priority' => 'Приоритет', ]; } /** * @return array[] */ public function behaviors() { return [ [ 'class' => TimestampBehavior::class, 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', 'value' => new Expression('NOW()'), ], ]; } /** * @return string[] */ public static function getStatus(): array { return [ self::STATUS_ACTIVE => 'Активен', self::STATUS_DISABLE => 'Выключен' ]; } /** * @return \yii\db\ActiveQuery */ public function getProject() { return $this->hasOne(Project::className(), ['id' => 'project_id']); } /** * @return \yii\db\ActiveQuery */ public function getTasks() { return $this->hasMany(ProjectTask::class, ['column_id' => 'id']) ->with('taskUsers') ->where(['status' => ProjectTask::STATUS_ACTIVE]) ->orderBy('priority'); } }