fix tasks

This commit is contained in:
iIronside 2023-10-13 14:25:40 +03:00
parent add34538f1
commit e712f2fc36
3 changed files with 62 additions and 59 deletions

View File

@ -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[] * @return string[]
*/ */

View File

@ -2,8 +2,8 @@
namespace common\services; namespace common\services;
use common\models\ProjectTask;
use common\models\ProjectTaskUser; use common\models\ProjectTaskUser;
use frontend\modules\api\models\ProjectTask;
class TaskService class TaskService
{ {

View File

@ -152,63 +152,5 @@ namespace frontend\modules\api\models;
*/ */
class ProjectTask extends \common\models\ProjectTask 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'
];
}
} }