From ea68ff760b6dcb9074ee2c4ad66c04e37b8940d7 Mon Sep 17 00:00:00 2001 From: Eelco Date: Sun, 4 Feb 2024 12:15:11 +0100 Subject: [PATCH] NavigationCountBadge filtered when isTenantAware --- src/Resources/MediaResource.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Resources/MediaResource.php b/src/Resources/MediaResource.php index 43f5ba4..eb96470 100644 --- a/src/Resources/MediaResource.php +++ b/src/Resources/MediaResource.php @@ -12,6 +12,7 @@ use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; +use Illuminate\Support\Facades\Config; use Illuminate\Support\HtmlString; use Illuminate\Support\Str; use function Awcodes\Curator\is_media_resizable; @@ -56,7 +57,12 @@ public static function getNavigationGroup(): ?string public static function getNavigationBadge(): ?string { return CuratorPlugin::get()->getNavigationCountBadge() ? - number_format(static::getModel()::count()) : null; + (Filament::hasTenancy() && Config::get('curator.is_tenant_aware')) ? + static::getEloquentQuery() + ->where(Filament::getTenantOwnershipRelationshipName() . '_id', Filament::getTenant()->id) + ->count() + : number_format(static::getModel()::count()) + : null; } public static function form(Form $form): Form