From 5cfd591140f1d9f51530c16dd5292ed58e21741c Mon Sep 17 00:00:00 2001 From: Kavalar Date: Fri, 2 Feb 2024 00:06:19 +0300 Subject: [PATCH] add file count to project task --- common/models/ProjectTask.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/models/ProjectTask.php b/common/models/ProjectTask.php index 2d40c5f..38867b1 100644 --- a/common/models/ProjectTask.php +++ b/common/models/ProjectTask.php @@ -52,7 +52,7 @@ class ProjectTask extends ActiveRecord /** * @return string[] */ - public static function priorityList() :array + public static function priorityList(): array { return [ self::PRIORITY_LOW => 'Низкий', @@ -182,6 +182,9 @@ class ProjectTask extends ActiveRecord 'comment_count' => function () { return $this->getCommentCount(); }, + 'file_count' => function () { + return $this->getFileCount(); + }, 'taskUsers', 'mark', 'execution_priority' @@ -196,6 +199,14 @@ class ProjectTask extends ActiveRecord return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count(); } + /** + * @return bool|int|string|null + */ + public function getFileCount() + { + return FileEntity::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => FileEntity::STATUS_ACTIVE])->count(); + } + /** * @return string[] */ @@ -244,7 +255,7 @@ class ProjectTask extends ActiveRecord */ public function getCompany(): ActiveQuery { - return $this->hasOne(Company::class,['id' => 'company_id']) + return $this->hasOne(Company::class, ['id' => 'company_id']) ->via('project'); }