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

RelationTrait::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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