diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 241b0f7b0e8a..514f4484c8f0 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -56,6 +56,11 @@ class AssetsController extends Controller public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array { + + // This handles the legacy audit endpoints :( + if ($action == 'audit') { + $action = 'audits'; + } $filter_non_deprecable_assets = false; /** @@ -154,8 +159,8 @@ public function index(Request $request, $action = null, $upcoming_status = null) * Handle due and overdue audits and checkin dates */ switch ($action) { - case 'audits': - + // Audit (singular) is left over from earlier legacy APIs + case 'audits' : switch ($upcoming_status) { case 'due': $assets->DueForAudit($settings); diff --git a/routes/api.php b/routes/api.php index 108f2ac23186..0581a046827d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -495,24 +495,17 @@ )->name('api.assets.show.byserial') ->where('any', '.*'); - // LEGACY URL - Get assets that are due or overdue for audit - Route::get('audit/{status}', - [ - Api\AssetsController::class, - 'index' - ] - )->name('api.asset.to-audit'); - // This gets the "due or overdue" API endpoints for audits and checkins + // This gets the "due or overdue" API endpoints for audit/audits and checkins Route::get('{action}/{upcoming_status}', [ Api\AssetsController::class, 'index' ] )->name('api.assets.list-upcoming') - ->where(['action' => 'audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']); + ->where(['action' => 'audit|audits|checkins', 'upcoming_status' => 'due|overdue|due-or-overdue']);