|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Tinyissue package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Tinyissue\Repository\User; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Relations; |
|
15
|
|
|
use Tinyissue\Contracts\Model\UserInterface; |
|
16
|
|
|
use Tinyissue\Contracts\Repository\Project\ProjectRepository; |
|
17
|
|
|
use Tinyissue\Contracts\Repository\User\CounterRepository as UserCounter; |
|
18
|
|
|
use Tinyissue\Model\Permission; |
|
19
|
|
|
use Tinyissue\Model\Project; |
|
20
|
|
|
use Tinyissue\Repository\RepositoryCounter; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class CounterRepository. |
|
24
|
|
|
* |
|
25
|
|
|
* @package Tinyissue\Repository\User |
|
26
|
|
|
*/ |
|
27
|
|
|
class CounterRepository extends RepositoryCounter implements UserCounter |
|
28
|
|
|
{ |
|
29
|
|
|
public function __construct(UserInterface $model) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->model = $model; |
|
|
|
|
|
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param int $deleted |
|
|
|
|
|
|
36
|
|
|
* |
|
37
|
|
|
* @return int |
|
38
|
|
|
*/ |
|
39
|
|
|
public function countNotDeleted() |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->model->notDeleted()->count(); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param int $deleted |
|
|
|
|
|
|
46
|
|
|
* |
|
47
|
|
|
* @return int |
|
48
|
|
|
*/ |
|
49
|
|
|
public function countDeleted() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->model->deleted()->count(); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Count number of created issues in a project. |
|
56
|
|
|
* |
|
57
|
|
|
* @param int $projectId |
|
58
|
|
|
* |
|
59
|
|
|
* @return int |
|
60
|
|
|
*/ |
|
61
|
|
View Code Duplication |
public function createdIssuesCount($projectId = 0) |
|
|
|
|
|
|
62
|
|
|
{ |
|
63
|
|
|
$issues = $this->issuesCreatedBy(); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
if (0 < $projectId) { |
|
66
|
|
|
$issues = $issues->where('project_id', '=', $projectId); |
|
67
|
|
|
} |
|
68
|
|
|
$issues->where('status', '=', Project\Issue::STATUS_OPEN); |
|
69
|
|
|
|
|
70
|
|
|
return $issues->count(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Returns all projects with open issue count. |
|
75
|
|
|
* |
|
76
|
|
|
* @param int $status |
|
77
|
|
|
* |
|
78
|
|
|
* @return Builder|Relations\BelongsToMany |
|
79
|
|
|
*/ |
|
80
|
|
View Code Duplication |
public function projectsWithCountOpenIssues($status = Project::STATUS_OPEN) |
|
|
|
|
|
|
81
|
|
|
{ |
|
82
|
|
|
if ($this->permission('project-all')) { |
|
|
|
|
|
|
83
|
|
|
$project = new Project(); |
|
84
|
|
|
|
|
85
|
|
|
return $project->projectsWithOpenIssuesCount($status, Project::PRIVATE_ALL); |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return $this->projects($status)->with('countOpenIssues'); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Count number of archived projects. |
|
93
|
|
|
* |
|
94
|
|
|
* @return int |
|
95
|
|
|
*/ |
|
96
|
|
|
public function countProjectsByStatus($status) |
|
97
|
|
|
{ |
|
98
|
|
|
if ($this->model->permission(Permission::PERM_PROJECT_ALL)) { |
|
99
|
|
|
return app()->make(ProjectRepository::class)->countProjectsByStatus($status); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
return $this->model->projects()->status($status)->count(); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..