vyuldashev / nova-permission

A Laravel Nova tool for Spatie's laravel-permission library
https://novapackages.com/packages/vyuldashev/nova-permission
419 stars 217 forks source link

Role and Permission name validation #145

Open ale1981 opened 4 years ago

ale1981 commented 4 years ago

The validation on the Role and Permission name field is wrong, you can have a Role or Permission with the same name but not the same name and guard, so I believe...

            Text::make(__('nova-permission-tool::roles.name'), 'name')
                ->rules(['required', 'string', 'max:255'])
                ->creationRules('unique:'.config('permission.table_names.roles'))
                ->updateRules('unique:'.config('permission.table_names.roles').',name,{{resourceId}}'),

should be ...



            Text::make(__('nova-permission-tool::roles.name'), 'name')
                ->rules(['required', 'string', 'max:255'])
                ->creationRules('unique:'.config('permission.table_names.roles').',name,,,guard_name,'.$request->guard_name)
                ->updateRules('unique:'.config('permission.table_names.roles').',name,{{resourceId}},id,guard_name,'.$request->guard_name),
FrancoFourmantin commented 3 years ago

+1 This is a problem when you have two guards and the same permission name.