Is it possible to disable the entire sidebar based on a user?

I am trying to disable the navigation menu for a specific user (based on their email), but when using the navigation method in the PanelProvider I get an error in the associated view
return $panel
->navigation(fn() => auth()->user()->email !== config('app.disabledSidebarEmail'))
return $panel
->navigation(fn() => auth()->user()->email !== config('app.disabledSidebarEmail'))
No description
2 Replies
MohamedSabil83
MohamedSabil833mo ago
If you mean hide the sections links, then you can achieve that in different ways: - Override the shouldRegisterNavigation() method in resources. - Override canAccess() method in custom pages. - Model policy.
LeandroFerreira
LeandroFerreira3mo ago
create a middleware. Inside the middleware you can use auth()->user() and filament()->getCurrentPanel()->navigation(...) https://github.com/filamentphp/filament/issues/7288#issuecomment-2061358409
GitHub
I cannot access to auth()->user() in panel · Issue #7288 · filament...
Package filament/filament Package Version v3.0.0-beta21 Laravel Version v10.0.0 Livewire Version v3.0.0 PHP Version 8.2.4 Problem description auth()->user() return null in panel class AdminPanel...