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

[feature] Limit BooleanGroup values #117

Open stickeegreg opened 4 years ago

stickeegreg commented 4 years ago

There doesn't seem to be an easy way to limit the roles / permissions that are available for selection in a BooleanGroup. I've done it my project by extending RoleBooleanGroup but it's not pretty as I have to duplicate some of the logic from the constructor and $this->options() is called twice.

It would be nice if RoleBooleanGroup and PermissionBooleanGroup had an optionsQuery method, similar to the way Nova Resources work - this could then be overridden in subclasses as needed.

Additionally, there's no validation that the values passed in are valid - it would be good to provide a validation rule.

My use case is I have multiple organisations that can sign up, but different organisations should have access to different roles. I can create a PR if you're interested.

pokono commented 4 years ago

Ended up doing the same! Thank you!