From ce0a3e6fbcfc9068dbf8508e47a98f3fcf1d8038 Mon Sep 17 00:00:00 2001 From: molin002 Date: Mon, 22 Feb 2021 10:58:12 +0100 Subject: [PATCH] add prefix to tables in raw select --- src/Repositories/Campaigns/BaseCampaignTenantRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/Campaigns/BaseCampaignTenantRepository.php b/src/Repositories/Campaigns/BaseCampaignTenantRepository.php index 5e43d69b..241a1bc7 100644 --- a/src/Repositories/Campaigns/BaseCampaignTenantRepository.php +++ b/src/Repositories/Campaigns/BaseCampaignTenantRepository.php @@ -43,7 +43,7 @@ public function getCounts(Collection $campaignIds, int $workspaceId): array ->where('sendportal_messages.workspace_id', $workspaceId); }) ->select('sendportal_campaigns.id as campaign_id') - ->selectRaw('count(sendportal_messages.id) as total') + ->selectRaw(sprintf('count(%ssendportal_messages.id) as total', DB::getTablePrefix())) ->selectRaw(sprintf('count(case when %ssendportal_messages.opened_at IS NOT NULL then 1 end) as opened', DB::getTablePrefix())) ->selectRaw(sprintf('count(case when %ssendportal_messages.clicked_at IS NOT NULL then 1 end) as clicked', DB::getTablePrefix())) ->selectRaw(sprintf('count(case when %ssendportal_messages.sent_at IS NOT NULL then 1 end) as sent', DB::getTablePrefix()))