From 7572edf59aae68c33a216534438acb407cc4325d Mon Sep 17 00:00:00 2001 From: CoRex Date: Thu, 7 Dec 2017 20:03:14 +0100 Subject: Added 'model:subtask:count:query' to SubtaskModel. --- app/Model/SubtaskModel.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index 1e652ae2..626ccbef 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -88,13 +88,22 @@ class SubtaskModel extends Base ->asc(self::TABLE.'.position'); } + /** + * Count by assignee and task status. + * + * @param integer $userId + * @return integer + */ public function countByAssigneeAndTaskStatus($userId) { - return $this->db->table(self::TABLE) + $query = $this->db->table(self::TABLE) ->eq('user_id', $userId) ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) - ->join(Taskmodel::TABLE, 'id', 'task_id') - ->count(); + ->join(Taskmodel::TABLE, 'id', 'task_id'); + + $this->hook->reference('model:subtask:count:query', $query); + + return $query->count(); } /** -- cgit v1.2.3