Skip to content

Commit

Permalink
NavigationCountBadge filtered when isTenantAware
Browse files Browse the repository at this point in the history
  • Loading branch information
Eelco committed Feb 4, 2024
1 parent 5b6cf2c commit ea68ff7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Resources/MediaResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ea68ff7

Please sign in to comment.