Skip to content

Commit

Permalink
Fix offene-umfragen badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschucki committed Mar 7, 2024
1 parent 2138475 commit bd3ad09
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,18 @@ public function getTabs(): array
$query->where('participant_id', auth()->id());
})->where('closes_at', '>', now())->orderBy('closes_at', 'DESC');
})->badge(function () {
$allPublicPolls = PublicPoll::where('visible_to_public', true)
->where('approved', true)
->where('in_review', false)
->where('closes_at', '>', now())
->withoutGlobalScope(SoftDeletingScope::class)
->count();

$allParticipatedPolls = PublicPoll::whereHas('participants', static function (Builder $query) {
$query->where('user_id', \Auth::id());
$notParticipatedPolls = PublicPoll::whereDoesntHave('participants', static function (Builder $query) {
$query->where('participant_id', \Auth::id());
})
->where('original_content_link', null)
->where('visible_to_public', true)
->where('approved', true)
->where('in_review', false)
->where('closes_at', '>', now())
->withoutGlobalScope(SoftDeletingScope::class)
->count();
->get();

return \Number::abbreviate($allPublicPolls - $allParticipatedPolls);
return \Number::abbreviate($notParticipatedPolls->count());
}),

'teilgenommen' => Tab::make('Teilgenommene Umfragen')->modifyQueryUsing(function (Builder $query) {
Expand Down

0 comments on commit bd3ad09

Please sign in to comment.