Completed
Push — master ( 91f8d9...64265e )
by Mohamed
09:45 queued 06:57
created

RelationTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 32
ccs 4
cts 6
cp 0.6667
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A attachments() 0 4 1
A activity() 0 4 1
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\Traits\Project\Issue\Comment;
13
14
use Illuminate\Database\Eloquent\Relations;
15
16
/**
17
 * RelationTrait is trait class containing the relationship methods for the Project\Issue\Comment model.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 *
21
 * @method Relations\HasMany   hasMany($related, $foreignKey = null, $localKey = null)
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
     * Comment can have many attachments.
39
     *
40
     * @return Relations\HasMany
41
     */
42 8
    public function attachments()
43
    {
44 8
        return $this->hasMany('Tinyissue\Model\Project\Issue\Attachment', 'comment_id');
45
    }
46
47
    /**
48
     * Comment can have one activity.
49
     *
50
     * @return Relations\HasOne
51
     */
52 8
    public function activity()
53
    {
54 8
        return $this->hasOne('Tinyissue\Model\User\Activity', 'action_id');
55
    }
56
}
57