ConsultancyProject_2_ETL/dashboard/routes/web.php

42 lines
1008 B
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
$propsPerRegion = Api::propertiesPerRegion();
$propsPerRegionName = [];
$propsPerRegionCounts = [];
foreach ($propsPerRegion as $el) {
$propsPerRegionName[] = $el['name'];
$propsPerRegionCounts[] = $el['count_properties'];
}
return view('overview', ["propsPerRegion" => [json_encode($propsPerRegionName), json_encode($propsPerRegionCounts)]]);
});
Route::get('/prop/{id}', function (int $id) {
$extractions = Api::propertyExtractions($id);
$data = [];
$dates = [];
foreach ($extractions as $ext) {
$series = [];
$dates[] = $ext['created_at'];
$extCalendar = json_decode($ext['calendar'], 1);
foreach ($extCalendar as $date => $status) {
$series[] = [$date, $status];
}
$data[] = $series;
}
return view('property', ["extractiondates" => json_encode($dates), "calendar" => $data]);
2024-12-18 10:14:56 +01:00
});