Code Duplication    Length = 44-44 lines in 3 locations

app/Model/RoleRelations.php 1 location

@@ 23-66 (lines=44) @@
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 Relations\HasMany
29
     */
30
    public function users()
31
    {
32
        return $this
33
            ->hasMany('Tinyissue\Model\User', '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 Relations\HasMany
42
     */
43
    public function projectUsers()
44
    {
45
        return $this->hasMany('Tinyissue\Model\Project\User');
46
    }
47
48
    /**
49
     * Role has many role permission.
50
     *
51
     * @return Relations\BelongsToMany
52
     */
53
    public function permissions()
54
    {
55
        return $this->belongsToMany(
56
            '\Tinyissue\Model\Permission',
57
            'roles_permissions',
58
            'role_id',
59
            'permission_id',
60
            'role_id'
61
        );
62
    }
63
64
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
65
    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
66
}
67

app/Repository/Traits/Relations/Role/Relations.php 1 location

@@ 24-67 (lines=44) @@
21
 *
22
 * @property static $this
23
 */
24
trait RelationTrait
25
{
26
    /**
27
     * Role has many users (One-many relationship of User::role).
28
     *
29
     * @return Relations\HasMany
30
     */
31
    public function users()
32
    {
33
        return $this
34
            ->hasMany('Tinyissue\Model\User', 'role_id', 'id')
35
            ->where('deleted', '=', User::NOT_DELETED_USERS)
36
            ->orderBy('firstname', 'asc');
37
    }
38
39
    /**
40
     * Role has many users in a project_users.
41
     *
42
     * @return Relations\HasMany
43
     */
44
    public function projectUsers()
45
    {
46
        return $this->hasMany('Tinyissue\Model\Project\User');
47
    }
48
49
    /**
50
     * Role has many role permission.
51
     *
52
     * @return Relations\BelongsToMany
53
     */
54
    public function permissions()
55
    {
56
        return $this->belongsToMany(
57
            '\Tinyissue\Model\Permission',
58
            'roles_permissions',
59
            'role_id',
60
            'permission_id',
61
            'role_id'
62
        );
63
    }
64
65
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
66
    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
67
}
68

app/Repository/Traits/Role/RelationTrait.php 1 location

@@ 24-67 (lines=44) @@
21
 *
22
 * @property static $this
23
 */
24
trait RelationTrait
25
{
26
    /**
27
     * Role has many users (One-many relationship of User::role).
28
     *
29
     * @return Relations\HasMany
30
     */
31
    public function users()
32
    {
33
        return $this
34
            ->hasMany('Tinyissue\Model\User', 'role_id', 'id')
35
            ->where('deleted', '=', User::NOT_DELETED_USERS)
36
            ->orderBy('firstname', 'asc');
37
    }
38
39
    /**
40
     * Role has many users in a project_users.
41
     *
42
     * @return Relations\HasMany
43
     */
44
    public function projectUsers()
45
    {
46
        return $this->hasMany('Tinyissue\Model\Project\User');
47
    }
48
49
    /**
50
     * Role has many role permission.
51
     *
52
     * @return Relations\BelongsToMany
53
     */
54
    public function permissions()
55
    {
56
        return $this->belongsToMany(
57
            '\Tinyissue\Model\Permission',
58
            'roles_permissions',
59
            'role_id',
60
            'permission_id',
61
            'role_id'
62
        );
63
    }
64
65
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
66
    abstract public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null);
67
}
68