@Dusted Try aliasing the column, as you’re selected it ((`count(created_a) and that’s the name it’ll use.
$dailyAverage = \DB::table('reviews')
->select(\DB::raw("to_char(date_trunc('day', created_at),'YYYY-MM-DD') as date, count(created_at) as count"))
->whereIn('location_id', $locationIds)
->groupBy('date')
->avg('count');