Code Duplication    Length = 44-52 lines in 2 locations

app/Model/Traits/Project/Issue/Comment/RelationTrait.php 1 location

@@ 25-76 (lines=52) @@
22
 * @method Relations\BelongsTo belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null)
23
 * @method Relations\HasOne    hasOne($related, $foreignKey = null, $localKey = null)
24
 */
25
trait RelationTrait
26
{
27
    /**
28
     * A comment has one user (inverse relationship of User::comments).
29
     *
30
     * @return Relations\BelongsTo
31
     */
32
    public function user()
33
    {
34
        return $this->belongsTo('\Tinyissue\Model\User', 'created_by');
35
    }
36
37
    /**
38
     * A comment has belongs to an issue
39
     *
40
     * @return Relations\BelongsTo
41
     */
42
    public function issue()
43
    {
44
        return $this->belongsTo('\Tinyissue\Model\Project\Issue', 'issue_id');
45
    }
46
47
    /**
48
     * Comment can have many attachments.
49
     *
50
     * @return Relations\HasMany
51
     */
52
    public function attachments()
53
    {
54
        return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'comment_id');
55
    }
56
57
    /**
58
     * Comment can have one activity.
59
     *
60
     * @return Relations\HasOne
61
     */
62
    public function activity()
63
    {
64
        return $this->hasOne('Tinyissue\Model\User\Activity', 'action_id');
65
    }
66
67
    /**
68
     * Comment can have many messages queue.
69
     *
70
     * @return Relations\HasMany
71
     */
72
    public function messagesQueue()
73
    {
74
        return $this->morphMany('Tinyissue\Model\Message\Queue', 'model');
75
    }
76
}
77

app/Model/Traits/Project/Note/RelationTrait.php 1 location

@@ 25-68 (lines=44) @@
22
 * @method Relations\BelongsTo belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null)
23
 * @method Relations\HasOne    hasOne($related, $foreignKey = null, $localKey = null)
24
 */
25
trait RelationTrait
26
{
27
    /**
28
     * Note created by a user.
29
     *
30
     * @return Relations\BelongsTo
31
     */
32
    public function createdBy()
33
    {
34
        return $this->belongsTo('Tinyissue\Model\User', 'created_by');
35
    }
36
37
    /**
38
     * Note belong to a project.
39
     *
40
     * @return Relations\BelongsTo
41
     */
42
    public function project()
43
    {
44
        return $this->belongsTo('Tinyissue\Model\Project', 'project_id');
45
    }
46
47
    /**
48
     * Note has a user activity record.
49
     *
50
     * @return Relations\HasOne
51
     */
52
    public function activity()
53
    {
54
        return $this
55
            ->hasOne('Tinyissue\Model\User\Activity', 'action_id')
56
            ->where('type_id', '=', Model\Activity::TYPE_NOTE);
57
    }
58
59
    /**
60
     * Note can have many messages queue.
61
     *
62
     * @return Relations\HasMany
63
     */
64
    public function messagesQueue()
65
    {
66
        return $this->morphMany('Tinyissue\Model\Message\Queue', 'model');
67
    }
68
}
69