Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’8mo agoβ€’
1 reply
iamlikemex

Tenant middleware doesn't apply on widgets

When I use the following in my panel provider, it applies perfectly well to all routes apart from when loading widgets.
->tenantMiddleware([
    'tenanted',
], isPersistent: true)
->tenantMiddleware([
    'tenanted',
], isPersistent: true)


This middleware basically calls
TenantManager::activate()
TenantManager::activate()
, and a global scope applied on all tenantable models then kicks into action to make sure every query is sufficiently filtered

Of course, I can update widgets use data filtered from
Filament::getTenant()
Filament::getTenant()
, but the point of the middleware is that I want to make sure that no cross-tenant leakage occurs, unless I explicitly want it to.

Is this possible, or do I need to come up with something different?

How do I best ensure that Widgets will also inherit tenanted middleware -> they know which tenant is active, so this should in theory be possible? Note that I don't want to globally apply such middleware across the whole application.

Also note that I am using
scoped
scoped
bindings on my app service provider and running octane.


The only other option I have found is to add to my
TenantManager::shouldApply()
TenantManager::shouldApply()
function the following condition, however this feels the wrong way to do this:

if (Filament::isServing() && Filament::hasTenancy() && Filament::getTenant()) {
    return true;
}

return $this->activated;
if (Filament::isServing() && Filament::hasTenancy() && Filament::getTenant()) {
    return true;
}

return $this->activated;


One assumes that Filament is doing some form of own-magic to set the
isServing
isServing
and active panel - I want to add my own magic too πŸ™‚
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel β€’ Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Overriding paginateTableQuery doesn't work on Widgets
FilamentFFilament / β“β”Šhelp
15mo ago
Theme doesn't apply on dashboard page
FilamentFFilament / β“β”Šhelp
2y ago
Tenant menu doesn't refresh when the tenant is updated.
FilamentFFilament / β“β”Šhelp
15mo ago
Show 404 if tenant doesn't exists
FilamentFFilament / β“β”Šhelp
15mo ago