kiritokatklian / nova-permission

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

Hide role permission #4

Closed kephren226 closed 2 years ago

kephren226 commented 2 years ago

Is there a way to hide Role and Permission from nova menu I want the admin user to be able to select a role when creating users but i don't want him to be able to add role or permision so no need for the menus How can i achive this ?

kephren226 commented 2 years ago

Actually i found a solution I just extended the Role class and redifiened the availableforNavigation function

phpMagpie commented 2 years ago

@kephren226 can you share relevant code snippets for how you achieved this?

Better still, can someone advise how this can be managed via configuration?

Cheers.

kephren226 commented 2 years ago

@kephren226 can you share relevant code snippets for how you achieved this?

Better still, can someone advise how this can be managed via configuration?

Cheers.

Hello what i have really done is extending the \Vyuldashev\NovaPermission\Role calss and redifining the availableForNavigation

so the class look like this

class DclRole extends \Vyuldashev\NovaPermission\Role { public static function availableForNavigation(Request $request) { return false; } } And when adding to NovaServiceProvider.php tools function use your custom class as like this

\Vyuldashev\NovaPermission\NovaPermissionTool::make()->roleResource(\App\Nova\DclRole::class) Hope it help