laraveldev04523
laraveldev04523
FFilament
Created by laraveldev04523 on 10/25/2023 in #❓┊help
Tenancy and BadgeCount - seems to cause an N+1 problem of sorts
First of all... I love Filament! I have a v3 installation running with Tenancy: user client client_user Very simple implementation. For each Resource, I would like to display the "badge count" in the sidebar navigation menu. Take a look at: public static function getNavigationBadge(): ?string { return static::getModel()::count(); } public static function getNavigationBadgeColor(): ?string { return static::getModel()::count() > 10 ? 'info' : 'gray'; } Straight from the docs. The problem is that I get 4 queries for "each" Tenant, of which I have 8 for a total of 32 duplicated queries. Has anyone ran into this kind of problem before? It seems that Filament::getTenant() works as it should, but is looping over every Tenant even though I'm only viewing data for one Tenant. Any advice is greatly appreciated!
20 replies