Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

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

src/Traits/HasRoles.php 1 location

@@ 88-105 (lines=18) @@
85
     *
86
     * @return $this
87
     */
88
    public function assignRole(...$roles)
89
    {
90
        $roles = collect($roles)
91
            ->flatten()
92
            ->map(function ($role) {
93
                return $this->getStoredRole($role);
94
            })
95
            ->each(function ($role) {
96
                $this->ensureGuardIsEqual($role);
97
            })
98
            ->all();
99
100
        $this->roles()->saveMany($roles);
101
102
        $this->forgetCachedPermissions();
103
104
        return $this;
105
    }
106
107
    /**
108
     * Revoke the given role from the model.