ConsultancyProject_2_ETL/dashboard/routes/web.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2024-12-18 10:14:56 +01:00
<?php
use Illuminate\Support\Facades\Route;
2024-12-18 15:14:13 +01:00
use App\Api;
2024-12-18 10:14:56 +01:00
Route::get('/', function () {
2024-12-18 15:14:13 +01:00
2024-12-18 19:52:06 +01:00
$propertiesGrowth = Api::propertiesGrowth();
2024-12-18 15:14:13 +01:00
$propsPerRegion = Api::propertiesPerRegion();
$propsPerRegionName = [];
$propsPerRegionCounts = [];
foreach ($propsPerRegion as $el) {
$propsPerRegionName[] = $el['name'];
$propsPerRegionCounts[] = $el['count_properties'];
}
2024-12-18 19:52:06 +01:00
$propertiesGeo = Api::propertiesGeo();
return view('overview', ["geo" => $propertiesGeo, "growth" => $propertiesGrowth, "propsPerRegion" => [json_encode($propsPerRegionName), json_encode($propsPerRegionCounts)]]);
2024-12-18 15:14:13 +01:00
});
Route::get('/prop/{id}', function (int $id) {
2024-12-18 19:52:06 +01:00
$propertyBase = Api::propertyBase($id);
2024-12-18 15:14:13 +01:00
$extractions = Api::propertyExtractions($id);
$propertyCapacities = Api::propertyCapacities($id);
2024-12-18 15:14:13 +01:00
$data = [];
$dates = [];
foreach ($extractions as $ext) {
$series = [];
$dates[] = $ext['created_at'];
2024-12-18 19:52:06 +01:00
2024-12-18 15:14:13 +01:00
$extCalendar = json_decode($ext['calendar'], 1);
2024-12-18 19:52:06 +01:00
2024-12-18 15:14:13 +01:00
foreach ($extCalendar as $date => $status) {
$series[] = [$date, $status];
}
$data[] = $series;
}
return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities]);
2024-12-18 10:14:56 +01:00
});