How to get currently logged user in AppPanelProvider?
In AppPanelProvider::panel() I have
$user = Auth::user();
, but the result is NULL
i.e. it seems that the currently logged user is not available in this method. Is there a way to have access to it in this method?6 Replies
In AppPanelProvider::panel() you are defining the middleware to be run, including authentication and sessions. Hence at that point the user cannot be known yet.
I'm defining there the UserMenu, which depends on the currently logged user. Is there a way to setup the UserMenu on another place?
I haven't started using filament v3 yet so. Does
AppPanelProvider
extends Filament\PanelProvider
?If yes it's not possible to get the current user you can read more from here https://stackoverflow.com/questions/37372357/laravel-how-to-get-current-user-in-appserviceprovider
Stack Overflow
Laravel - How to get current user in AppServiceProvider
So I am usually getting the current user using Auth::user() and when I am determining if a user is actually logged in Auth::check. However this doesn't seem to work in my AppServiceProvider. I am u...
Is there another way to have a UserMenu with elements based on the currently logged User?
For the reference, I did it with closure on hidden():
is it possible to do this in middleware ?
and I think You can access the
Gate
facade in service provider