| @@ 112-128 (lines=17) @@ | ||
| 109 | * |
|
| 110 | * @return Eloquent\Relations\HasOne |
|
| 111 | */ |
|
| 112 | public function closedIssuesCount($limitByUser = null) |
|
| 113 | { |
|
| 114 | $query = $this |
|
| 115 | ->hasOne( |
|
| 116 | 'Tinyissue\Model\Project\Issue', |
|
| 117 | 'project_id' |
|
| 118 | ) |
|
| 119 | ->selectRaw('project_id, count(*) as aggregate') |
|
| 120 | ->where('status', '=', Project\Issue::STATUS_CLOSED) |
|
| 121 | ->groupBy('project_id'); |
|
| 122 | ||
| 123 | if ($limitByUser && $limitByUser->isUser() && $this->isPrivateInternal()) { |
|
| 124 | $query->where('created_by', '=', $limitByUser->id); |
|
| 125 | } |
|
| 126 | ||
| 127 | return $query; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * For eager loading: include number of open issues. |
|
| @@ 137-153 (lines=17) @@ | ||
| 134 | * |
|
| 135 | * @return Eloquent\Relations\HasOne |
|
| 136 | */ |
|
| 137 | public function openIssuesCount(User $limitByUser = null) |
|
| 138 | { |
|
| 139 | $query = $this |
|
| 140 | ->hasOne( |
|
| 141 | 'Tinyissue\Model\Project\Issue', |
|
| 142 | 'project_id' |
|
| 143 | ) |
|
| 144 | ->selectRaw('project_id, count(*) as aggregate') |
|
| 145 | ->where('status', '=', Project\Issue::STATUS_OPEN) |
|
| 146 | ->groupBy('project_id'); |
|
| 147 | ||
| 148 | if ($limitByUser && $limitByUser->isUser() && $this->isPrivateInternal()) { |
|
| 149 | $query->where('created_by', '=', $limitByUser->id); |
|
| 150 | } |
|
| 151 | ||
| 152 | return $query; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Return projects with count of open & closed issues. |
|