我通过返回相同的属性来比较2个集合。预期的结果应该返回1个剩余的用户,我得到的输出是一个空数组。
//110 users
$brand_users = BrandUser::whereSegmentId($campaign->segment_id)
->orderBy('brand_user_id', 'ASC')
->get(['brand_user_id']);
//109 users
$campaign_results = \App\CampaignResult::whereCampaignId($campaign_job->campaign_id)
->orderBy('brand_user_id', 'ASC')
->get(['brand_user_id']);
$diff = $brand_users->diff($campaign_results);
return $diff->all();
//output
[]
//expected
return the remaining brand_user_id
答案 0 :(得分:0)
答案是在集合上使用 - > pluck(' brand_user_id')而不是get()