Skip to content

Commit

Permalink
Change order of stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Sep 6, 2024
1 parent dad4b91 commit c24fccf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Widgets/MailStatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ class MailStatsWidget extends BaseWidget

protected function getStats(): array
{
$bouncedMails = Mail::where(fn ($query) => $query->softBounced()->orWhere(fn ($query) => $query->hardBounced()))->count();
$bouncedMails = Mail::where(fn($query) => $query->softBounced()->orWhere(fn($query) => $query->hardBounced()))->count();
$openedMails = Mail::opened()->count();
$deliveredMails = Mail::delivered()->count();
$clickedMails = Mail::clicked()->count();

$mailCount = Mail::count();

$widgets[] = Stat::make(__('Bounced'), number_format(($bouncedMails / $mailCount) * 100, 1) . '%')
->label(__('Bounced'))
->description($bouncedMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('danger')
->url(route('filament.admin.resources.mails.index', ['activeTab' => 'bounced']));
$widgets[] = Stat::make(__('Delivered'), number_format(($deliveredMails / $mailCount) * 100, 1) . '%')
->label(__('Delivered'))
->description($deliveredMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('success');

$widgets[] = Stat::make(__('Opened'), number_format(($openedMails / $mailCount) * 100, 1) . '%')
->label(__('Opened'))
Expand All @@ -36,11 +35,12 @@ protected function getStats(): array
->description($clickedMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('clicked');

$widgets[] = Stat::make(__('Delivered'), number_format(($deliveredMails / $mailCount) * 100, 1) . '%')
->label(__('Delivered'))
->description($deliveredMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('success');
$widgets[] = Stat::make(__('Bounced'), number_format(($bouncedMails / $mailCount) * 100, 1) . '%')
->label(__('Bounced'))
->description($bouncedMails . ' ' . __('of') . ' ' . $mailCount . ' ' . __('emails'))
->color('danger')
->url(route('filament.admin.resources.mails.index', ['activeTab' => 'bounced']));

return $widgets;
}
}
}

0 comments on commit c24fccf

Please sign in to comment.