How to load different ListPage based on permission on multi-tenant resource?

Hello,
I am using multi-tenancy on my Filament Project and using Spatie roles and permissions.

I am trying to load different ListPage on my resource based on the permission as you can see in the code below, but the getPages() doesn't recognize Filament::getTenant()->id which is causing the problem to check for the permission for the authenticated user.
    public static function getPages(): array
    {
        $user = auth()->user();

        setPermissionsTeamId(Filament::getTenant()->id);
        return [
            'index' => ($user->can('create booking')) ? Pages\ListBookings::route('/') : ListUsers::route('/'),
            'create' => Pages\CreateBooking::route('/create'),
            'edit' => Pages\EditBooking::route('/{record}/edit'),
        ];
    }


My question is how do I make this load different index route based on the permission please?
Thank you
Was this page helpful?