Skip to content

Commit

Permalink
Update MailStatsWidget.php to use config Model
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmKevinMcKee authored Dec 24, 2024
1 parent 805b27d commit 73b6403
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Resources/MailResource/Widgets/MailStatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ class MailStatsWidget extends BaseWidget

protected function getStats(): array
{
$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();
$class = config('mails.models.mail');

$bouncedMails = $class::where(fn ($query) => $query->softBounced()->orWhere(fn ($query) => $query->hardBounced()))->count();
$openedMails = $class::opened()->count();
$deliveredMails = $class::delivered()->count();
$clickedMails = $class::clicked()->count();

$mailCount = $class::count();

if ($mailCount === 0) {
return [];
Expand Down

0 comments on commit 73b6403

Please sign in to comment.