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

@@ 94-111 (lines=18) @@
91
     *
92
     * @return $this
93
     */
94
    public function assignRole(...$roles)
95
    {
96
        $roles = \collect($roles)
97
            ->flatten()
98
            ->map(function ($role) {
99
                return $this->getStoredRole($role);
100
            })
101
            ->each(function ($role) {
102
                $this->ensureModelSharesGuard($role);
103
            })
104
            ->all();
105
106
        $this->roles()->saveMany($roles);
107
108
        $this->forgetCachedPermissions();
109
110
        return $this;
111
    }
112
113
    /**
114
     * Revoke the given role from the model.