Skip to content

Commit

Permalink
rcm parish
Browse files Browse the repository at this point in the history
  • Loading branch information
tomahock committed Jan 29, 2024
1 parent e580892 commit 31c2ba5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/Http/Controllers/RCMController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace App\Http\Controllers;

use App\Models\RCM;
use App\Tools\RCMTool;
use Laravel\Lumen\Routing\Controller;
use App\Models\RCMForJS;
use Nyholm\Psr7\Request;
use voku\helper\UTF8;

class RCMController extends Controller
{
Expand Down Expand Up @@ -55,4 +58,32 @@ public function after()

return response()->json($geoJson);
}

public function parish(Request $request)
{
$concelho = $request->get('concelho');
$concelho = UTF8::ucwords(UTF8::strtolower(trim($concelho)));

$risk = RCM::where('concelho', $concelho)
->orderBy('created', 'desc')
->limit(1)
->get();

if (isset($risk[0])) {
abort(404);
}

$responseRisk = [
'today' => $risk[0]['hoje'],
'tomorrow' => $risk[0]['amanha'],
'after' => $risk[0]['depois'],
];

$response = [
'success' => true,
'data' => $responseRisk,
];

return response()->json($response);
}
}
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
$router->get('today', '\App\Http\Controllers\RCMController@today');
$router->get('tomorrow', '\App\Http\Controllers\RCMController@tomorrow');
$router->get('after', '\App\Http\Controllers\RCMController@after');
$router->get('parish', '\App\Http\Controllers\RCMController@parish');
});

$router->group(['prefix' => 'planes'], function () use ($router) {
Expand Down

0 comments on commit 31c2ba5

Please sign in to comment.