Skip to content

Commit

Permalink
add prefix to tables in raw select
Browse files Browse the repository at this point in the history
  • Loading branch information
molin002 committed Feb 22, 2021
1 parent fa1ae8b commit e3c8ce4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Repositories/Campaigns/BaseCampaignTenantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function getCounts(Collection $campaignIds, int $workspaceId): array
})
->select('sendportal_campaigns.id as campaign_id')
->selectRaw('count(sendportal_messages.id) as total')
->selectRaw('count(case when sendportal_messages.opened_at IS NOT NULL then 1 end) as opened')
->selectRaw('count(case when sendportal_messages.clicked_at IS NOT NULL then 1 end) as clicked')
->selectRaw('count(case when sendportal_messages.sent_at IS NOT NULL then 1 end) as sent')
->selectRaw('count(case when sendportal_messages.bounced_at IS NOT NULL then 1 end) as bounced')
->selectRaw('count(case when sendportal_messages.sent_at IS NULL then 1 end) as pending')
->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()))
->selectRaw(sprintf('count(case when %ssendportal_messages.bounced_at IS NOT NULL then 1 end) as bounced', DB::getTablePrefix()))
->selectRaw(sprintf('count(case when %ssendportal_messages.sent_at IS NULL then 1 end) as pending', DB::getTablePrefix()))
->groupBy('sendportal_campaigns.id')
->orderBy('sendportal_campaigns.id')
->get();
Expand Down

0 comments on commit e3c8ce4

Please # to comment.