我正在尝试将以下总计聚合到新集合中以使用报表,total\u outbound的子查询没有返回特定活动作业id的正确计数
$campaign_jobs_summary = new Collection();
foreach ($campaign_jobs as $campaign_job) {
$campaign_job_totals = DB::table("campaign_jobs")
->select('campaign_jobs.deploy_date', 'campaign_jobs.campaign_id', 'campaign_jobs.id as campaign_job_id', 'campaign_jobs.start_time as local_start_time',
'campaign_jobs.start_time as local_start_time', 'campaign_jobs.start_time as local_start_time', 'campaign_jobs.start_time as local_start_time',
DB::raw("(select companies.name from companies join brands on brands.company_id = companies.id where brands.id =$campaign->brand_id) as company"),
DB::raw("(select count(id) from campaign_results where direction = 'outbound-api' and reCall = '0' and campaign_job_id =$campaign_job->id ) as total_outbound"),
DB::raw("(select count(id) as aggregate from campaign_results where com_platform_status = 'completed' and direction = 'outbound-api' and campaign_job_id = $campaign_job->id ) as total_answered")
)
->whereCampaignId(35)
->get();
$campaign_jobs_summary = $campaign_jobs_summary->push($campaign_job_totals);
}
return $campaign_jobs_summary;
2条答案
按热度按时间dfddblmv1#
将代码行更改为
dldeef672#
好的,问题是在循环中以get()而不是first()的形式返回查询,并通过campaign\u jobs.id将wherecampaignid更改为whereid