Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

@@ 27-44 (lines=18) @@
24
     * @return $this
25
     * @throws GuardDoesNotMatch
26
     */
27
    public function givePermissionTo(...$permissions)
28
    {
29
        $permissions = \collect($permissions)
30
            ->flatten()
31
            ->map(function ($permission) {
32
                return $this->getStoredPermission($permission);
33
            })
34
            ->each(function ($permission) {
35
                $this->ensureModelSharesGuard($permission);
36
            })
37
            ->all();
38
39
        $this->permissions()->saveMany($permissions);
40
41
        $this->forgetCachedPermissions();
42
43
        return $this;
44
    }
45
46
    /**
47
     * Remove all current permissions and set the given ones.

src/Traits/HasRoles.php 1 location

@@ 111-128 (lines=18) @@
108
     *
109
     * @return $this
110
     */
111
    public function assignRole(...$roles)
112
    {
113
        $roles = \collect($roles)
114
            ->flatten()
115
            ->map(function ($role) {
116
                return $this->getStoredRole($role);
117
            })
118
            ->each(function ($role) {
119
                $this->ensureModelSharesGuard($role);
120
            })
121
            ->all();
122
123
        $this->roles()->saveMany($roles);
124
125
        $this->forgetCachedPermissions();
126
127
        return $this;
128
    }
129
130
    /**
131
     * Revoke the given role from the model.