authorization in NavigationItem

I have this in my
AppServiceProvider
class:

 Filament::serving(function () {
            Filament::registerNavigationGroups([

                NavigationGroup::make()
                    ->label('Admin')
                    ->collapsible(false)
                    ->items([
                        NavigationItem::make('roles')
                            ->visible(auth()->user()->can('manage-admin-settings')),
                        NavigationItem::make('users')
                            ->visible(auth()->user()->can('manage-admin-settings'))
                    ])


            ]);
        });


Based on the documentation, it indicates I can add a NavigationItem and conditionally show/hide it based on the role of the user. However, I believe that at this point in the execution, the app is still booting and the authorized user isn't available. I'm getting an error that I can't call can() on null.
Was this page helpful?