The Filament Admin panel is designed to show the User Menu only when a user is logged in. This is because the User Menu typically contains user-specific actions and information, such as profile settings or logout functionality. However, if you want to display a login option or similar actions when no user is logged in, you will need to customize the navigation bar instead of the User Menu.
Here's how you can add a "Log In" link to the top navigation bar that appears when no user is logged in. You can use the topNavigation() method in your Filament resource or through a service provider to modify the navigation items conditionally based on the user's authentication status.
use Filament\Facades\Filament;
use Filament\Navigation\UserMenuItem;
use Filament\Navigation\NavigationItem;
Filament::serving(function () {
Filament::registerNavigationItems([
NavigationItem::make('Login')
->icon('heroicon-o-login')
->url(route('filament.auth.login'))
->isVisible(!Filament::auth()->check()), // Only visible when no user is logged in
]);
});
In this example, the isVisible() method is used to conditionally display the "Login" navigation item only when no user is logged in (!Filament::auth()->check()). This approach ensures that the login link is only shown to guests, maintaining a clean and relevant user interface for authenticated users.
Remember to adjust the route (route('filament.auth.login')) and icon (icon('heroicon-o-login')) according to your application's configuration and your aesthetic preferences.
This solution modifies the top navigation bar and does not use the User Menu, as the User Menu is inherently designed to be user-specific and thus hidden when no user session exists.