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

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