<?php
// Add this group to app/Config/Routes.php
$routes->group('api/v1', ['namespace' => 'App\Controllers\Api'], static function($routes) {
    // Assignments
    $routes->get('assignments', 'AssignmentController::index');
    $routes->post('assignments', 'AssignmentController::store');
    $routes->get('assignments/(:num)', 'AssignmentController::show/$1');
    $routes->put('assignments/(:num)', 'AssignmentController::update/$1');
    $routes->delete('assignments/(:num)', 'AssignmentController::delete/$1');
    $routes->get('assignments/student/(:num)', 'AssignmentController::student/$1');

    // Attendance
    $routes->get('attendance', 'AttendanceController::index');
    $routes->post('attendance', 'AttendanceController::store');
    $routes->get('attendance/(:num)', 'AttendanceController::show/$1');
    $routes->put('attendance/(:num)', 'AttendanceController::update/$1');
    $routes->delete('attendance/(:num)', 'AttendanceController::delete/$1');
    $routes->get('attendance/student/(:num)', 'AttendanceController::student/$1');

    // Attendance Tracking
    $routes->post('attendance-tracking/record', 'AttendanceTrackingController::record');
    $routes->get('attendance-tracking/violations', 'AttendanceTrackingController::violations');
    $routes->get('attendance-tracking/student/(:num)', 'AttendanceTrackingController::student/$1');

    // Authorized Users
    $routes->get('authorized-users', 'AuthorizedUsersController::index');
    $routes->post('authorized-users', 'AuthorizedUsersController::store');
    $routes->get('authorized-users/(:num)', 'AuthorizedUsersController::show/$1');
    $routes->delete('authorized-users/(:num)', 'AuthorizedUsersController::delete/$1');

    // Broadcast Email
    $routes->post('broadcast-email/send', 'BroadcastEmailController::send');
    $routes->get('broadcast-email/parents', 'BroadcastEmailController::parents');

    // Calendar
    $routes->get('calendar', 'CalendarController::index');
    $routes->post('calendar', 'CalendarController::store');
    $routes->get('calendar/(:num)', 'CalendarController::show/$1');
    $routes->put('calendar/(:num)', 'CalendarController::update/$1');
    $routes->delete('calendar/(:num)', 'CalendarController::delete/$1');

    // Classes
    $routes->get('classes', 'ClassController::index');
    $routes->get('classes/(:num)', 'ClassController::show/$1');
    $routes->get('classes/(:num)/students', 'ClassController::students/$1');

    // Class Preparation
    $routes->get('class-preparation', 'ClassPreparationController::index');
    $routes->get('class-preparation/(:num)', 'ClassPreparationController::show/$1');
    $routes->post('class-preparation/calculate', 'ClassPreparationController::calculate');

    // Communications
    $routes->get('communications', 'CommunicationController::index');
    $routes->post('communications/send', 'CommunicationController::send');
    $routes->get('communications/conversation', 'CommunicationController::conversation');
    $routes->delete('communications/(:num)', 'CommunicationController::delete/$1');
});

// API Docs routes
$routes->get('docs', 'App\Controllers\DocsController::index');
$routes->get('docs/api', 'App\Controllers\ApiDocsController::index', ['filter' => 'apiDocsAuth']);
$routes->get('docs/api/public', 'App\Controllers\ApiDocsController::public');
