<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
//$routes->get('/', 'Home::index');
// Endpoint bebas filter (public)
$routes->group('api', ['filter' => 'cors'], function($routes) {
  $routes->post('auth/login', 'AuthController::login');
});

// Endpoint butuh JWT
$routes->group('api', ['filter' => 'auth'], function($routes) {
    // Ambil data siswa berdasarkan NISN
$routes->get('siswa/(:num)', 'Siswa::show/$1');

// Optional: ambil berdasarkan nama
$routes->get('siswa/nama/(:any)', 'Siswa::byNama/$1');

// Optional: jika frontend kirim NISN langsung
$routes->get('siswa/nisn/(:num)', 'Siswa::byNISN/$1');
$routes->get('siswa/username/(:any)', 'Siswa::byUsername/$1');
    // dst...
 $routes->get('absensi', 'Absensi::index');
    $routes->post('absensi', 'Absensi::create');
    $routes->get('absensi/(:num)', 'Absensi::show/$1');
    $routes->get('dashboard', 'Dashboard::index');
    $routes->get('dashboard/rombel', 'Dashboard::rombel');  // <<-- ini yang ditambahkan
});