ConsultancyProject_2_ETL/dashboard/routes/web.php

73 lines
2.2 KiB
PHP

<?php
use Illuminate\Support\Facades\Route;
use App\Api;
Route::get('/', function () {
$regionPropertyCapacities = Api::regionPropertyCapacities(-1);
$propertiesGrowth = Api::propertiesGrowth();
$propsPerRegion = Api::propertiesPerRegion();
$propsPerRegionName = [];
$propsPerRegionCounts = [];
foreach ($propsPerRegion as $el) {
$propsPerRegionName[] = $el['name'];
$propsPerRegionCounts[] = $el['count_properties'];
}
$propertiesGeo = Api::propertiesGeo();
return view('overview', ["regionPropertiesCapacities" => $regionPropertyCapacities, "geo" => $propertiesGeo, "growth" => $propertiesGrowth, "propsPerRegion" => [json_encode($propsPerRegionName), json_encode($propsPerRegionCounts)]]);
});
Route::get('/prop/{id}', function (int $id) {
$propertyBase = Api::propertyBase($id);
$extractions = Api::propertyExtractions($id);
$propertyCapacities = Api::propertyCapacities($id);
$propertyNeighbours = Api::propertyNeighbours($id);
//$regionCapacities = Api::regionCapacities(-1);
$regionCapacities = [];
$propertyCapacitiesMonthly = [];
$propertyCapacitiesDaily = [];
foreach ($extractions as $extraction) {
$propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
$propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $extraction['created_at']);
}
$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', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly, 'capacitiesDaily' => $propertyCapacitiesDaily, 'regionCapacities' => $regionCapacities, 'neighbours' => $propertyNeighbours]);
});
Route::get('/region/{id}', function (int $id) {
$regionCapacities = Api::regionCapacities($id);
dump($regionCapacities);
return view('region', ['capacities' => $regionCapacities]);
});