59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use Illuminate\Support\Facades\Route;
 | 
						|
use App\Api;
 | 
						|
 | 
						|
Route::get('/', function () {
 | 
						|
 | 
						|
    $regionHeat = Api::regionCapacities(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', ["heat" => $regionHeat, "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);
 | 
						|
    $propertyCapacitiesMonthly = [];
 | 
						|
    $propertyCapacitiesDaily = [];
 | 
						|
 | 
						|
    foreach ($extractions as $extraction) {
 | 
						|
        $propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
 | 
						|
    }
 | 
						|
 | 
						|
    //dump($propertyCapacitiesMonthly);
 | 
						|
 | 
						|
 | 
						|
    $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]);
 | 
						|
});
 |