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

RoleRelations   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A users() 0 7 1
A projectUsers() 0 4 1
hasMany() 0 1 ?
belongsToMany() 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;
13
14
use Illuminate\Database\Eloquent\Relations;
15
16
/**
17
 * RelationTrait is trait class containing the relationship methods for the Role model.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 *
21
 * @property static $this
22
 */
23
trait RoleRelations
24
{
25
    /**
26
     * Role has many users (One-many relationship of User::role).
27
     *
28
     * @return User
29
     */
30
    public function users()
31
    {
32
        return $this
33
            ->hasMany(User::class, 'role_id', 'id')
34
            ->where('deleted', '=', User::NOT_DELETED_USERS)
35
            ->orderBy('firstname', 'asc');
36
    }
37
38
    /**
39
     * Role has many users in a project_users.
40
     *
41
     * @return Project\User
42
     */
43
    public function projectUsers()
44
    {
45
        return $this->hasMany(Project\User::class);
46
    }
47
48
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
49
    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
50
}
51