Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

@@ 202-219 (lines=18) @@
199
     *
200
     * @return $this
201
     */
202
    public function givePermissionTo(...$permissions)
203
    {
204
        $permissions = collect($permissions)
205
            ->flatten()
206
            ->map(function ($permission) {
207
                return $this->getStoredPermission($permission);
208
            })
209
            ->each(function ($permission) {
210
                $this->ensureModelSharesGuard($permission);
211
            })
212
            ->all();
213
214
        $this->permissions()->saveMany($permissions);
215
216
        $this->forgetCachedPermissions();
217
218
        return $this;
219
    }
220
221
    /**
222
     * Remove all current permissions and set the given ones.

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.