Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

@@ 251-268 (lines=18) @@
248
     *
249
     * @return $this
250
     */
251
    public function givePermissionTo(...$permissions)
252
    {
253
        $permissions = collect($permissions)
254
            ->flatten()
255
            ->map(function ($permission) {
256
                return $this->getStoredPermission($permission);
257
            })
258
            ->each(function ($permission) {
259
                $this->ensureModelSharesGuard($permission);
260
            })
261
            ->all();
262
263
        $this->permissions()->saveMany($permissions);
264
265
        $this->forgetCachedPermissions();
266
267
        return $this;
268
    }
269
270
    /**
271
     * 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.