'Alle Regionen', 'region_id' => -1]; $regionPropertyCapacities = Api::regionPropertiesCapacities(-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', ["regions" => $regionBase, "regionPropertiesCapacities" => $regionPropertyCapacities, "geo" => $propertiesGeo, "growth" => $propertiesGrowth, "propsPerRegion" => [json_encode($propsPerRegionName), json_encode($propsPerRegionCounts)]]); }); Route::get('/prop/{id}', function (int $id) { $propertyBase = Api::propertyBase($id); $calendars = Api::propertyExtractions($id); $propertyCapacities = Api::propertyCapacities($id); $propertyNeighbours = Api::propertyNeighbours($id); $regionCapacitiesRegion = Api::regionCapacities($propertyBase[0]['region_id']); $regionCapacitiesAll = Api::regionCapacities(-1); $regionCapacities = [[],[]]; $propertyCapacitiesMonthly = []; $propertyCapacitiesDaily = []; foreach ($propertyCapacities['dates'] as $date) { $propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $date); $propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $date); } // filter out all date, which were not scraped for the property foreach ($regionCapacitiesAll['dates'] as $index => $date) { if(in_array($date, $propertyCapacities['dates'])){ $regionCapacities[0][] = $regionCapacitiesAll['capacities'][$index]; } } foreach ($regionCapacitiesRegion['dates'] as $index => $date) { if(in_array($date, $propertyCapacities['dates'])){ $regionCapacities[1][] = $regionCapacitiesRegion['capacities'][$index]; } } // prepare data for calendar chart $data = []; $dates = []; foreach ($calendars as $el) { $series = []; $calendar = json_decode($el['calendar'], 1); foreach ($calendar as $date => $status) { $series[] = [$date, $status]; } $data[] = $series; } return view('property', [ 'base' => $propertyBase[0], 'extractiondates' => json_encode($propertyCapacities['dates']), 'calendar' => $data, 'propertyCapacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly, 'capacitiesDaily' => $propertyCapacitiesDaily, 'regionCapacities' => $regionCapacities, 'neighbours' => $propertyNeighbours ]); }); Route::get('/region/{id}', function (int $id) { $regionBaseAll = Api::regionBase(-1); $regionBaseAll[] = ['region_name' => 'Alle Regionen', 'region_id' => -1]; $regionBaseRegion = $id >= 0 ? Api::regionBase($id) : [['region_name' => 'Alle Regionen']]; $regionPropertiesCapacities = Api::regionPropertiesCapacities($id); $regionCapacitiesRegion = Api::regionCapacities($id); $regionCapacitiesAll = Api::regionCapacities(-1); $regionCapacities = [$regionCapacitiesAll, $regionCapacitiesRegion]; return view('region', ['regions' => $regionBaseAll, 'region' => $regionBaseRegion, 'region_id' => $id, 'regionCapacities' => $regionCapacities, 'regionPropertiesCapacities' => $regionPropertiesCapacities]); });