outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
278 stars 97 forks source link

feat: add optional authorization at page level #165

Closed shawnheide closed 1 year ago

shawnheide commented 1 year ago

Hello, I've been using this package for a bit and was having issues with using the settings globally, but also restricting access to some of the pages.

I added an authorization parameter to the addSettingsFields methods and used it to filter the pages on the Nova side. That way the settings are available outside Nova, but still restricted to people with permission. There is also a config for whether the default should be to hide or show if authorization is null.

Let me know if you think it's useful or if there's anything that I should change. No worries if it's too far out of scope for the project. Thanks!

shawnheide commented 1 year ago

Sorry, I think this was a bit premature. I haven't quite figured out where to register the settings to have it available globally and have the user accessible to authorize.

It seems that the settings need to be registered in the booted to be globally accessible and in serving to handle permissions. Happy to hear other ideas.

I think something like a SettingsPage described here would be helpful.