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\Project\Issue; |
13
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Collection; |
15
|
|
|
use Tinyissue\Model\Project; |
16
|
|
|
use Tinyissue\Model\Tag; |
17
|
|
|
use Tinyissue\Model\User\Activity as UserActivity; |
18
|
|
|
use Tinyissue\Repository\Repository; |
19
|
|
|
|
20
|
|
|
class Fetcher extends Repository |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var Project\Issue |
24
|
|
|
*/ |
25
|
|
|
protected $model; |
26
|
|
|
|
27
|
|
|
public function __construct(Project\Issue $model) |
28
|
|
|
{ |
29
|
|
|
$this->model = $model; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getByNumber($number) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the status tag. |
39
|
|
|
* |
40
|
|
|
* @return Tag |
41
|
|
|
*/ |
42
|
|
|
public function getStatusTag() |
43
|
|
|
{ |
44
|
|
|
return $this->tagOfType(Tag::GROUP_STATUS); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns the type tag. |
49
|
|
|
* |
50
|
|
|
* @return Tag |
51
|
|
|
*/ |
52
|
|
|
public function getTypeTag() |
53
|
|
|
{ |
54
|
|
|
return $this->tagOfType(Tag::GROUP_TYPE); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns the resolution tag. |
59
|
|
|
* |
60
|
|
|
* @return Tag |
61
|
|
|
*/ |
62
|
|
|
public function getResolutionTag() |
63
|
|
|
{ |
64
|
|
|
return $this->tagOfType(Tag::GROUP_RESOLUTION); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get collection of issue activities. |
69
|
|
|
* |
70
|
|
|
* @return Collection |
71
|
|
|
*/ |
72
|
|
|
public function getGeneralActivities() |
73
|
|
|
{ |
74
|
|
|
$activities = $this->model->generalActivities()->get(); |
75
|
|
|
|
76
|
|
|
$activities->each(function (UserActivity $activity) { |
77
|
|
|
$activity->setRelation('issue', $this->model); |
78
|
|
|
$activity->setRelation('project', $this->model->project); |
79
|
|
|
}); |
80
|
|
|
|
81
|
|
|
return $activities; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get collection of issue comments. |
86
|
|
|
* |
87
|
|
|
* @return Collection |
88
|
|
|
*/ |
89
|
|
|
public function getCommentActivities() |
90
|
|
|
{ |
91
|
|
|
$this->model->setRelation('attachments.issue', $this->model); |
92
|
|
|
$this->model->attachments->each(function (Project\Issue\Attachment $attachment) { |
93
|
|
|
$attachment->setRelation('issue', $this->model); |
94
|
|
|
}); |
95
|
|
|
|
96
|
|
|
$activities = $this->model->commentActivities()->get(); |
97
|
|
|
|
98
|
|
|
$activities->each(function (UserActivity $activity) { |
99
|
|
|
$activity->setRelation('issue', $this->model); |
100
|
|
|
$activity->setRelation('project', $this->model->project); |
101
|
|
|
}); |
102
|
|
|
|
103
|
|
|
return $activities; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Return tag by it group name. |
108
|
|
|
* |
109
|
|
|
* @param string $group |
110
|
|
|
* |
111
|
|
|
* @return Tag |
112
|
|
|
*/ |
113
|
|
|
protected function tagOfType($group) |
114
|
|
|
{ |
115
|
|
|
return $this->model->tags |
116
|
|
|
->where('parent.name', $group) |
117
|
|
|
->first(); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.