F
Filamentβ€’5mo ago
Nathan

Is there a way to hide the whole navigation panel depending on role?

One role in a system i am building is supposed to have access only to a single page so, they would like the whole nav panel not to show as it makes no sense. Is there a way to accomplish this?
7 Replies
Vp
Vpβ€’5mo ago
Try #bezhansalleh-shield And you assign user to particular page (role/permission) and when that user login they should only see those permissions (single page)
Nathan
NathanOPβ€’5mo ago
thanks but that only hides those pages from the navigation. And you end up with a panel that's empty. I am trying to hide the whole nav panel.
Vp
Vpβ€’5mo ago
check like ->navigation(fn(): bool => auth()->user()->can_see_navigation)
Nathan
NathanOPβ€’5mo ago
Thank you! would be great if this worked but it gives an error: Call to a member function getNavigation() on false πŸ˜•
->navigation(false) does work but would disable for everyone
Vp
Vpβ€’5mo ago
can you check like this for specific user? w8 https://github.com/filamentphp/filament/blob/3.x/packages/panels/src/Panel/Concerns/HasNavigation.php#L27 By looking the source code, it should accept closure tho.. not sure why it's not working
Tanker
Tankerβ€’5mo ago
Yup, I'm wondering the same question, you have, SuperAdmin, Admin, "Manager", "Crew"... Super and Admin should be able to see and manage roles and permissions, but the rest shouldn't, they shouldn't even be able to see it, you can hide them but they still able to manage it if they have the URL... I haven't seen any official solution for that.
Want results from more Discord servers?
Add your server