From e712f2fc36ffec7fde96c8343be0c1a69788961c Mon Sep 17 00:00:00 2001 From: iIronside Date: Fri, 13 Oct 2023 14:25:40 +0300 Subject: [PATCH] fix tasks --- common/models/ProjectTask.php | 61 +++++++++++++++++++++ common/services/TaskService.php | 2 +- frontend/modules/api/models/ProjectTask.php | 58 -------------------- 3 files changed, 62 insertions(+), 59 deletions(-) diff --git a/common/models/ProjectTask.php b/common/models/ProjectTask.php index be19aac..a717f54 100644 --- a/common/models/ProjectTask.php +++ b/common/models/ProjectTask.php @@ -97,6 +97,67 @@ class ProjectTask extends ActiveRecord ]; } + /** + * @return string[] + */ + public function fields(): array + { + return [ + 'id', + 'project_id', + 'project_name' => function () { + return $this->project->name ?? null; + }, + 'title', + 'created_at', + 'updated_at', + 'dead_line', + 'description', + 'status', + 'column_id', + 'user_id', + 'user' => function () { + return [ + "fio" => $this->user->userCard->fio ?? $this->user->id, + "avatar" => $this->user->userCard->photo ?? '', + ]; + }, + 'executor_id', + 'priority', + 'executor' => function () { + if ($this->executor) { + return [ + "fio" => $this->executor->userCard->fio ?? $this->executor->username, + "avatar" => $this->executor->userCard->photo ?? '', + ]; + } + + return null; + }, + 'comment_count' => function () { + return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count(); + }, + 'taskUsers', + 'mark' + ]; + } + + /** + * @return string[] + */ + public function extraFields(): array + { + return [ + 'timers', + 'column' => function () { + return [ + 'column_title' => $this->column->title ?? null + ]; + }, + 'mark' + ]; + } + /** * @return string[] */ diff --git a/common/services/TaskService.php b/common/services/TaskService.php index c2a9b92..835cd82 100644 --- a/common/services/TaskService.php +++ b/common/services/TaskService.php @@ -2,8 +2,8 @@ namespace common\services; +use common\models\ProjectTask; use common\models\ProjectTaskUser; -use frontend\modules\api\models\ProjectTask; class TaskService { diff --git a/frontend/modules/api/models/ProjectTask.php b/frontend/modules/api/models/ProjectTask.php index ed80fd9..78d6de0 100644 --- a/frontend/modules/api/models/ProjectTask.php +++ b/frontend/modules/api/models/ProjectTask.php @@ -152,63 +152,5 @@ namespace frontend\modules\api\models; */ class ProjectTask extends \common\models\ProjectTask { - /** - * @return string[] - */ - public function fields(): array - { - return [ - 'id', - 'project_id', - 'project_name' => function () { - return $this->project->name ?? null; - }, - 'title', - 'created_at', - 'updated_at', - 'dead_line', - 'description', - 'status', - 'column_id', - 'user_id', - 'user' => function () { - return [ - "fio" => $this->user->userCard->fio ?? $this->user->id, - "avatar" => $this->user->userCard->photo ?? '', - ]; - }, - 'executor_id', - 'priority', - 'executor' => function () { - if ($this->executor) { - return [ - "fio" => $this->executor->userCard->fio ?? $this->executor->username, - "avatar" => $this->executor->userCard->photo ?? '', - ]; - } - return null; - }, - 'comment_count' => function () { - return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count(); - }, - 'taskUsers', - ]; - } - - /** - * @return string[] - */ - public function extraFields(): array - { - return [ - 'timers', - 'column' => function () { - return [ - 'column_title' => $this->column->title ?? null - ]; - }, - 'mark' - ]; - } } \ No newline at end of file