Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasRoles.php 1 location

@@ 81-98 (lines=18) @@
78
     *
79
     * @return $this
80
     */
81
    public function assignRole(...$roles)
82
    {
83
        $roles = collect($roles)
84
            ->flatten()
85
            ->map(function ($role) {
86
                return $this->getStoredRole($role);
87
            })
88
            ->each(function ($role) {
89
                $this->ensureModelSharesGuard($role);
90
            })
91
            ->all();
92
93
        $this->roles()->saveMany($roles);
94
95
        $this->forgetCachedPermissions();
96
97
        return $this;
98
    }
99
100
    /**
101
     * Revoke the given role from the model.

src/Traits/HasPermissions.php 1 location

@@ 212-229 (lines=18) @@
209
     *
210
     * @return $this
211
     */
212
    public function givePermissionTo(...$permissions)
213
    {
214
        $permissions = collect($permissions)
215
            ->flatten()
216
            ->map(function ($permission) {
217
                return $this->getStoredPermission($permission);
218
            })
219
            ->each(function ($permission) {
220
                $this->ensureModelSharesGuard($permission);
221
            })
222
            ->all();
223
224
        $this->permissions()->saveMany($permissions);
225
226
        $this->forgetCachedPermissions();
227
228
        return $this;
229
    }
230
231
    /**
232
     * Remove all current permissions and set the given ones.