© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
Proculair B.V.

Tenancy: access tenant in `canAccessPanel` function

Hi,

The
canAccessPanel
canAccessPanel
function on the
User
User
model is an ideal place to check if the users tenant has access to that functionality.

Unfortunately the
Tenant
Tenant
model is not loaded until after the firs invocation of
canAccessPanel
canAccessPanel
.

User.php
public function canAccessPanel(Panel $panel): bool
{
    return match ($panel->getId()) {
        'app'     => true,
        'tickets' => Feature::activate(\App\Features\Tickets::class),
        default   => true,
    };
}
public function canAccessPanel(Panel $panel): bool
{
    return match ($panel->getId()) {
        'app'     => true,
        'tickets' => Feature::activate(\App\Features\Tickets::class),
        default   => true,
    };
}


AppServiceProvider.php
Feature::resolveScopeUsing(fn () => Filament::getTenant());
Feature::useMorphMap();
Feature::discover();
Feature::resolveScopeUsing(fn () => Filament::getTenant());
Feature::useMorphMap();
Feature::discover();


App\Features\Tickets.php
class Tickets
{
    public function resolve(): mixed
    {
        return true;
    }
}
class Tickets
{
    public function resolve(): mixed
    {
        return true;
    }
}


Is it possible to get the tenant loaded in the
canAccessPanel
canAccessPanel
method or is there another good way to achieve this?
image.png
image.png
Solution
there is a function getCurrentPanel not sure if it will help
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

Tenancy + canAccessPanel
FilamentFFilament / ❓┊help
3y ago
Disable tenant menu with tenancy
FilamentFFilament / ❓┊help
3y ago
Multi-Tenancy HasManyThrough Tenant Relationship
FilamentFFilament / ❓┊help
3y ago
Tenancy: associate created record with tenant in CreateAction
FilamentFFilament / ❓┊help
3y ago