$sums = $detailed->mapWithKeys (function ($group, $key) { return [$key => $group->sum ('sales_price')]; });