Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

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

src/Traits/HasRoles.php 1 location

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