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

UserRelations   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A message() 0 4 1
A project() 0 4 1
belongsTo() 0 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