Code Duplication    Length = 18-18 lines in 2 locations

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.

src/Traits/HasPermissions.php 1 location

@@ 48-65 (lines=18) @@
45
     * @return $this
46
     * @throws GuardDoesNotMatch
47
     */
48
    public function givePermissionTo(...$permissions)
49
    {
50
        $permissions = collect($permissions)
51
            ->flatten()
52
            ->map(function ($permission) {
53
                return $this->getStoredPermission($permission);
54
            })
55
            ->each(function ($permission) {
56
                $this->ensureModelSharesGuard($permission);
57
            })
58
            ->all();
59
60
        $this->permissions()->saveMany($permissions);
61
62
        $this->forgetCachedPermissions();
63
64
        return $this;
65
    }
66
67
    /**
68
     * Remove all current permissions and set the given ones.