|
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\Model\User; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Relations; |
|
15
|
|
|
use Tinyissue\Model; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* ActivityRelations is trait class containing the relationship method for the User\Activity model. |
|
19
|
|
|
* |
|
20
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
|
21
|
|
|
* |
|
22
|
|
|
* @property static $this |
|
23
|
|
|
*/ |
|
24
|
|
|
trait ActivityRelations |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Returns the project issue this activity is belongs to by the item_id, which can hold the issue id. |
|
28
|
|
|
* |
|
29
|
|
|
* @return Model\Project\Issue |
|
30
|
|
|
*/ |
|
31
|
|
|
public function issue() |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->belongsTo(Model\Project\Issue::class, 'item_id'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the user this activity is belongs to. |
|
38
|
|
|
* |
|
39
|
|
|
* @return Model\User |
|
40
|
|
|
*/ |
|
41
|
|
|
public function user() |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->belongsTo(Model\User::class, 'user_id'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns the user that was assigned to the issue. Only for reassign activity. |
|
48
|
|
|
* |
|
49
|
|
|
* @return Model\User |
|
50
|
|
|
*/ |
|
51
|
|
|
public function assignTo() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->belongsTo(Model\User::class, 'action_id'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* User activity has one activity type. |
|
58
|
|
|
* |
|
59
|
|
|
* @return Model\Activity |
|
60
|
|
|
*/ |
|
61
|
|
|
public function activity() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->belongsTo(Model\Activity::class, 'type_id'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Returns the comment this activity belongs to if any. |
|
68
|
|
|
* |
|
69
|
|
|
* @return Model\Project\Issue\Comment |
|
70
|
|
|
*/ |
|
71
|
|
|
public function comment() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->belongsTo(Model\Project\Issue\Comment::class, 'action_id'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns the project his activity belongs to. |
|
78
|
|
|
* |
|
79
|
|
|
* @return Model\Project |
|
80
|
|
|
*/ |
|
81
|
|
|
public function project() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->belongsTo(Model\Project::class, 'parent_id'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Returns the note this activity belongs to if any. |
|
88
|
|
|
* |
|
89
|
|
|
* @return Model\Project\Note |
|
90
|
|
|
*/ |
|
91
|
|
|
public function note() |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->belongsTo(Model\Project\Note::class, 'action_id'); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null); |
|
97
|
|
|
} |
|
98
|
|
|
|