Code Duplication    Length = 18-18 lines in 2 locations

src/Traits/HasPermissions.php 1 location

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

src/Traits/HasRoles.php 1 location

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