Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasRoles.php 1 location

@@ 156-173 (lines=18) @@
153
     *
154
     * @return $this
155
     */
156
    public function assignRole(...$roles)
157
    {
158
        $roles = collect($roles)
159
            ->flatten()
160
            ->map(function ($role) {
161
                return $this->getStoredRole($role);
162
            })
163
            ->each(function ($role) {
164
                $this->ensureModelSharesGuard($role);
165
            })
166
            ->all();
167
168
        $this->roles()->saveMany($roles);
169
170
        $this->forgetCachedPermissions();
171
172
        return $this;
173
    }
174
175
    /**
176
     * Revoke the given role from the model.

src/Traits/HasPermissions.php 1 location

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