Role::permissions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace NukaCode\Users\Models;
4
5
use App\Models\BaseModel;
6
7
class Role extends BaseModel
8
{
9
    public $table = 'acl_roles';
10
11
    /**
12
     * A role may be given various permissions.
13
     *
14
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
15
     */
16
    public function permissions()
17
    {
18
        return $this->belongsToMany(Permission::class, 'acl_permission_role');
19
    }
20
21
    /**
22
     * Grant the given permission to a role.
23
     *
24
     * @param  Permission $permission
25
     * @return mixed
26
     */
27
    public function givePermissionTo(Permission $permission)
28
    {
29
        return $this->permissions()->save($permission);
30
    }
31
}
32