feat(dashboard): add price history, caching, and i18n
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Features\Dashboard\Services;
|
||||
|
||||
use App\Features\Dashboard\Contracts\PriceRepository;
|
||||
use App\Features\Dashboard\Data\DashboardData;
|
||||
|
||||
class DashboardService
|
||||
{
|
||||
@@ -10,11 +11,25 @@ class DashboardService
|
||||
public PriceRepository $repository
|
||||
) {}
|
||||
|
||||
public function getDashboardData(): array
|
||||
public function getDashboardData(): DashboardData
|
||||
{
|
||||
return [
|
||||
'electricity' => $this->repository->retrieveElectricity(),
|
||||
'gas' => $this->repository->retrieveGas(),
|
||||
];
|
||||
$electricity = $this->repository->retrieveElectricity();
|
||||
$eCheapest = $electricity->min('total_price_tax_included');
|
||||
$eDurable = $electricity->min('sustainability_score');
|
||||
$ePriciest = $electricity->max('total_price_tax_included');
|
||||
|
||||
$gas = $this->repository->retrieveGas();
|
||||
$gCheapest = $gas->min('total_price_tax_included');
|
||||
$gPriciest = $gas->min('total_price_tax_included');
|
||||
|
||||
return new DashboardData(
|
||||
$electricity,
|
||||
$eCheapest,
|
||||
$eDurable,
|
||||
$ePriciest,
|
||||
$gas,
|
||||
$gCheapest,
|
||||
$gPriciest
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user