Спасибо
Дмитрий за подсказку. В итоге сделал вот так:
Вместо трёх таблиц создал одну, и сделал выборку с помощью groupBy
$postbacks = DB::table('postbacks as p')
->select(
DB::raw('DATE(p.created_at) as date'),
'u.name as user_name',
'c.name as campaign_name',
'c.domain',
'pr.name as provider_name',
'pr.commission',
DB::raw('SUM(p.income) AS t_income'),
DB::raw('SUM(p.cost) AS t_cost')
)
->join('campaigns as c', 'p.campaign_id', '=', 'c.id')
->join('providers as pr', 'c.provider_id', '=', 'pr.id')
->join('users as u', 'c.user_id', '=', 'u.id')
->whereBetween('p.created_at', ['2023-08-15', '2023-08-17'])
->where('c.user_id', 1)
->groupBy(DB::raw('DATE(p.created_at)'), 'c.id')
->orderBy('date', 'ASC')
->get();