Code Duplication    Length = 10-10 lines in 2 locations

src/Models/Permission.php 1 location

@@ 30-39 (lines=10) @@
27
        $this->setTable(config('permission.table_names.permissions'));
28
    }
29
30
    public static function create(array $attributes = [])
31
    {
32
        $attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');
33
34
        if (static::getPermissions()->where('name', $attributes['name'])->where('guard_name', $attributes['guard_name'])->first()) {
35
            throw PermissionAlreadyExists::create($attributes['name'], $attributes['guard_name']);
36
        }
37
38
        return static::query()->create($attributes);
39
    }
40
41
    /**
42
     * A permission can be applied to roles.

src/Models/Role.php 1 location

@@ 31-40 (lines=10) @@
28
        $this->setTable(config('permission.table_names.roles'));
29
    }
30
31
    public static function create(array $attributes = [])
32
    {
33
        $attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');
34
35
        if (static::where('name', $attributes['name'])->where('guard_name', $attributes['guard_name'])->first()) {
36
            throw RoleAlreadyExists::create($attributes['name'], $attributes['guard_name']);
37
        }
38
39
        return static::query()->create($attributes);
40
    }
41
42
    /**
43
     * A role may be given various permissions.