Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

@@ 19-36 (lines=18) @@
16
     *
17
     * @return $this
18
     */
19
    public function givePermissionTo(...$permissions)
20
    {
21
        $permissions = collect($permissions)
22
            ->flatten()
23
            ->map(function ($permission) {
24
                return $this->getStoredPermission($permission);
25
            })
26
            ->each(function ($permission) {
27
                $this->ensureModelSharesGuard($permission);
28
            })
29
            ->all();
30
31
        $this->permissions()->saveMany($permissions);
32
33
        $this->forgetCachedPermissions();
34
35
        return $this;
36
    }
37
38
    /**
39
     * Remove all current permissions and set the given ones.

src/Traits/HasRoles.php 1 location

@@ 163-180 (lines=18) @@
160
     *
161
     * @return $this
162
     */
163
    public function assignRole(...$roles)
164
    {
165
        $roles = collect($roles)
166
            ->flatten()
167
            ->map(function ($role) {
168
                return $this->getStoredRole($role);
169
            })
170
            ->each(function ($role) {
171
                $this->ensureModelSharesGuard($role);
172
            })
173
            ->all();
174
175
        $this->roles()->saveMany($roles);
176
177
        $this->forgetCachedPermissions();
178
179
        return $this;
180
    }
181
182
    /**
183
     * Revoke the given role from the model.