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

CommentRelations::morphMany()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 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\Project\Issue;
13
14
use Illuminate\Database\Eloquent\Relations;
15
use Tinyissue\Model;
16
17
/**
18
 * CommentRelations is trait class containing the relationship methods for the Project\Issue\Comment model.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property static $this
23
 */
24
trait CommentRelations
25
{
26
    /**
27
     * A comment has one user (inverse relationship of User::comments).
28
     *
29
     * @return Model\User
30
     */
31
    public function user()
32
    {
33
        return $this->belongsTo(Model\User::class, 'created_by');
34
    }
35
36
    /**
37
     * A comment has belongs to an issue.
38
     *
39
     * @return Model\Project\Issue
40
     */
41
    public function issue()
42
    {
43
        return $this->belongsTo(Model\Project\Issue::class, 'issue_id');
44
    }
45
46
    /**
47
     * Comment can have many attachments.
48
     *
49
     * @return Model\Project\Issue\Attachment
50
     */
51
    public function attachments()
52
    {
53
        return $this->hasMany(Model\Project\Issue\Attachment::class, 'comment_id');
54
    }
55
56
    /**
57
     * Comment can have one activity.
58
     *
59
     * @return Model\User\Activity
60
     */
61
    public function activity()
62
    {
63
        return $this->hasOne(Model\User\Activity::class, 'action_id');
64
    }
65
66
    /**
67
     * Comment can have many messages queue.
68
     *
69
     * @return Model\Message\Queue
70
     */
71
    public function messagesQueue()
72
    {
73
        return $this->morphMany(Model\Message\Queue::class, 'model');
74
    }
75
76
    abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
77
78
    abstract public function hasOne($related, $foreignKey = null, $localKey = null);
79
80
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
81
82
    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
83
}
84