Handle audit *and* audits for urls

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-24 16:55:56 +01:00
parent de57d71bf1
commit 5fb43dd159
2 changed files with 15 additions and 3 deletions

View file

@ -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;
/**
@ -155,30 +160,37 @@ class AssetsController extends Controller
*/
switch ($action) {
// Audit (singular) is left over from earlier legacy APIs
case ('audit' || 'audits'):
case 'audits' :
\Log::error('audit/audits');
switch ($upcoming_status) {
case 'due':
\Log::error('due');
$assets->DueForAudit($settings);
break;
case 'overdue':
\Log::error('overdue');
$assets->OverdueForAudit();
break;
case 'due-or-overdue':
\Log::error('due-or-overdue');
$assets->DueOrOverdueForAudit($settings);
break;
}
break;
case 'checkins':
\Log::error('checkins');
switch ($upcoming_status) {
case 'due':
\Log::error('due');
$assets->DueForCheckin($settings);
break;
case 'overdue':
\Log::error('overdue');
$assets->OverdueForCheckin();
break;
case 'due-or-overdue':
\Log::error('due-or-overdue');
$assets->DueOrOverdueForCheckin($settings);
break;
}

View file

@ -498,7 +498,7 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
// 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,