From e287a656c5321a07f55010acdc1059c82c63c1b0 Mon Sep 17 00:00:00 2001 From: Nguyen Tu Date: Tue, 10 Dec 2024 15:27:36 +0700 Subject: [PATCH] Fix: slow campaign query --- src/Models/Campaign.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/Campaign.php b/src/Models/Campaign.php index 3ffac05d..fe7842f8 100644 --- a/src/Models/Campaign.php +++ b/src/Models/Campaign.php @@ -180,7 +180,7 @@ public function getActiveSubscriberCountAttribute(): int public function getSentCountAttribute(): int { - return $this->sent_messages->count(); + return $this->sent_messages()->count(); } public function getUnsentCountAttribute(): int @@ -258,7 +258,7 @@ public function getBounceRatioAttribute() public function getMergedContentAttribute(): ?string { if ($this->template_id) { - return str_replace(['{{content}}', '{{ content }}'], $this->content, $this->template->content); + return str_replace(['{{content}}', '{{ content }}'], $this->content, $this->template()->value('content')); } return $this->content;