Completed
Push — develop-3.0 ( 360277...bd5ff0 )
by Mohamed
06:52
created

AttachmentRelations::issue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Project\Issue;
13
14
use Illuminate\Database\Eloquent\Relations;
15
use Tinyissue\Model;
16
17
/**
18
 * AttachmentRelations is trait class containing the relationship methods for the Project\Issue\Attachment model.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property static $this
23
 */
24
trait AttachmentRelations
25
{
26
    /**
27
     * An attachment is belong to one issue  (inverse relationship of Project\Issue::attachments).
28
     *
29
     * @return Model\Project\Issue
30
     */
31
    public function issue()
32
    {
33
        return $this->belongsTo(Model\Project\Issue::class, 'issue_id');
34
    }
35
36
    /**
37
     * An attachment has one user upladed to (inverse relationship of User::attachments).
38
     *
39
     * @return Model\User
40
     */
41
    public function user()
42
    {
43
        return $this->belongsTo(Model\User::class, 'uploaded_by');
44
    }
45
46
    /**
47
     * An attachment can belong to a comment (inverse relationship of Comments::attachments).
48
     *
49
     * @return Model\Project\Issue\Comment
50
     */
51
    public function comment()
52
    {
53
        return $this->belongsTo(Model\Project\Issue\Comment::class, 'comment_id');
54
    }
55
56
    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
57
}
58