Skip to content

Commit

Permalink
add subregion filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tomahock committed Mar 18, 2024
1 parent 9a9567b commit 535b982
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Http/Controllers/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 535b982

Please sign in to comment.