© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•17mo ago•
3 replies
Prosp30

Tenant users - hide certain statuses from the menu

I am trying to show tenant users and their teams in two areas of my app.

One is a filament resource page called Users, a table view with users in the current tenant that have the following status in team_user table: A, B

Code for it

Users.php

    public function teams(): BelongsToMany
    {
        return $this->belongsToMany(Team::class)->withTimestamps()->withPivot('team_id', 'user_id', 'status', 'created_at', 'updated_at')->where('team_user.status',  '<>', 'B');
    }

    public function team() {
        return Filament::getTenant();
    }

    public function teams(): BelongsToMany
    {
        return $this->belongsToMany(Team::class)->withTimestamps()->withPivot('team_id', 'user_id', 'status', 'created_at', 'updated_at')->where('team_user.status',  '<>', 'B');
    }

    public function team() {
        return Filament::getTenant();
    }


Also, on the resource page for Users

public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()->with('teams');
        //return parent::getEloquentQuery()->where('team_user.status', 'A')->with('teams');
    }
public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()->with('teams');
        //return parent::getEloquentQuery()->where('team_user.status', 'A')->with('teams');
    }


The problem that I am facing is the following. In the table, users for the tenant are displayed correctly (show me all users that are in status A or I, don't show users in status B. That works fine. On the tenancy menu (top left on the navbar), the user should see the tenant only if the user is in status A. Right now the user can see the tenant even when in status I.

How to make different logic for these two segments of the app, in other words, how to control tenancy menu, when to show the tenant and when not to show it? It is directly connected to teams() relationship on the User model, so changing it there affects both the resource page and the tenancy menu.
Solution
Figured it out. The view uses getTenants()

public function getTenants(Panel $panel): Collection
{
     return $this->teams()->where('team_user.status', 'A')->get();
}
public function getTenants(Panel $panel): Collection
{
     return $this->teams()->where('team_user.status', 'A')->get();
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Hide panel switching menu for certain users?
FilamentFFilament / ❓┊help
3y ago
Exempt users from tenant
FilamentFFilament / ❓┊help
3y ago
tenant menu
FilamentFFilament / ❓┊help
2y ago
Customizing the tenant menu
FilamentFFilament / ❓┊help
3y ago