Completed
Push — master ( d42b43...5ac77a )
by ARCANEDEV
8s
created

PermissionRelationships::roles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php namespace Arcanedev\LaravelAuth\Models\Relationships;
2
3
use Arcanedev\LaravelAuth\Models\Role;
4
5
/**
6
 * Class     PermissionRelationships
7
 *
8
 * @package  Arcanedev\LaravelAuth\Traits
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @method  \Illuminate\Database\Eloquent\Relations\BelongsToMany  belongsToMany(string $related, string $table = null, string $foreignKey = null, string $otherKey = null, string $relation = null)
12
 */
13
trait PermissionRelationships
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Relationships
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Permission belongs to many roles.
21
     *
22
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
23
     */
24
    public function roles()
25
    {
26
        $model = config('laravel-auth.roles.model', Role::class);
27
28
        return $this
29
            ->belongsToMany($model, 'permission_role', 'permission_id', 'role_id')
30
            ->withTimestamps();
31
    }
32
}
33