diff --git a/app/Http/Controllers/IncidentController.php b/app/Http/Controllers/IncidentController.php index b03b5b6..4591a30 100644 --- a/app/Http/Controllers/IncidentController.php +++ b/app/Http/Controllers/IncidentController.php @@ -38,6 +38,9 @@ public function active(Request $request): JsonResponse $csv = $request->get('csv'); $csv2 = $request->get('csv2'); + $subRegion = $request->get('subRegion'); + + $incidents = Incident::isActive() ->when(!$all, function ($query, $all){ return $query->isFire(); @@ -47,6 +50,8 @@ public function active(Request $request): JsonResponse return $query->isOtherFire(); })->when($concelho, function ($query, $concelho){ return $query->where('concelho', $concelho); + })->when($subRegion, function ($query, $subRegion){ + return $query->where('sub_regiao', $subRegion); }) ->orderBy('created_at', 'desc') ->paginate($limit); @@ -334,6 +339,8 @@ public function search(IncidentSearchRequest $request) $extend = $request->get('extend'); $concelho = $request->get('concelho'); + $subRegion = $request->get('subRegion'); + $incidents = Incident::when($day, function($query, $day){ return $query->whereBetween( @@ -362,6 +369,8 @@ public function search(IncidentSearchRequest $request) return $query->isFMA(); })->when($naturezaCode, function ($query, $naturezaCode){ return $query->where('naturezaCode', (string)$naturezaCode); + })->when($subRegion, function ($query, $subRegion){ + return $query->where('sub_regiao', (string)$subRegion); }); $csv2 = $request->get('csv2');