Fix ServerList Filter query (#977)

This commit is contained in:
MartinOscar 2025-02-08 12:45:36 +01:00 committed by GitHub
parent 9ec2f6eae1
commit 5797b790fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,19 +50,21 @@ class ListServers extends ListRecords
public function getTabs(): array
{
$baseQuery = auth()->user()->accessibleServers();
$all = auth()->user()->accessibleServers();
$my = (clone $all)->where('owner_id', auth()->user()->id);
$other = (clone $all)->whereNot('owner_id', auth()->user()->id);
return [
'my' => Tab::make('My Servers')
->badge(fn () => $baseQuery->where('owner_id', auth()->user()->id)->count())
->modifyQueryUsing(fn (Builder $query) => $query->where('owner_id', auth()->user()->id)),
->badge(fn () => $my->count())
->modifyQueryUsing(fn () => $my),
'other' => Tab::make('Others\' Servers')
->badge(fn (Builder $query) => $query->whereNot('owner_id', auth()->user()->id)->count())
->modifyQueryUsing(fn (Builder $query) => $query->whereNot('owner_id', auth()->user()->id)),
->badge(fn () => $other->count())
->modifyQueryUsing(fn () => $other),
'all' => Tab::make('All Servers')
->badge($baseQuery->count()),
->badge($all->count()),
];
}
}