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

UserRelations::belongsTo()

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;
13
14
use Illuminate\Database\Eloquent\Relations;
15
use Tinyissue\Model;
16
17
/**
18
 * UserRelations is trait class containing the relationship methods for the Project\User model.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 *
22
 * @property static $this
23
 */
24
trait UserRelations
25
{
26
    /**
27
     * Returns the instance of the user in the project.
28
     *
29
     * @return Model\User
30
     */
31
    public function user()
32
    {
33
        return $this->belongsTo(Model\User::class, 'user_id')->orderBy('firstname', 'ASC');
34
    }
35
36
    /**
37
     * Returns the instance of the message in the project.
38
     *
39
     * @return Model\Message
40
     */
41
    public function message()
42
    {
43
        return $this->belongsTo(Model\Message::class, 'message_id');
44
    }
45
46
    /**
47
     * Returns the instance of the project.
48
     *
49
     * @return Model\Project
50
     */
51
    public function project()
52
    {
53
        return $this->belongsTo(Model\Project::class, 'project_id')->orderBy('name', 'ASC');
54
    }
55
56
    abstract public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null);
57
}
58