repository->retrieveElectricity(); $eNow = $electricity->whereBetween('startDate', [$now->copy()->subHour(), $now])->first(); $eCheapest = $electricity->where('totalPriceTaxIncluded', $electricity->min('totalPriceTaxIncluded'))->first(); $eDurable = $electricity->where('sustainabilityScore', $electricity->min('sustainabilityScore'))->first(); $ePriciest = $electricity->where('totalPriceTaxIncluded', $electricity->max('totalPriceTaxIncluded'))->first(); $gas = $this->repository->retrieveGas(); $gNow = $gas->whereBetween('startDate', [$now->copy()->setHour(0), $now])->first(); $gCheapest = $gas->where('totalPriceTaxIncluded', $gas->min('totalPriceTaxIncluded'))->first(); $gPriciest = $gas->where('totalPriceTaxIncluded', $gas->min('totalPriceTaxIncluded'))->first(); return new DashboardData( $eNow, $eCheapest, $eDurable, $ePriciest, $gNow, $gCheapest, $gPriciest ); } }