<?php

namespace Modules\AdministrativeUnits\Config;

use Config;
// Create a new instance of our RouteCollection class.
$routes = Config\Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
    require SYSTEMPATH . 'Config/Routes.php';
}

$routes->get('api/districts', '\Modules\AdministrativeUnits\Controllers\Api::getDistrictList');
$routes->get('api/counties', '\Modules\AdministrativeUnits\Controllers\Api::getCountyList');
$routes->get('api/subcounties', '\Modules\AdministrativeUnits\Controllers\Api::getSubCountyList');
$routes->get('api/parishes', '\Modules\AdministrativeUnits\Controllers\Api::getParishList');
$routes->get('api/villages', '\Modules\AdministrativeUnits\Controllers\Api::getVillageList');

$routes->get('api/village/search', '\Modules\AdministrativeUnits\Controllers\Api::getVillageSearch');

$routes->group('admin-units', ['namespace' => 'Modules\AdministrativeUnits\Controllers'], static function ($routes) {
    $routes->get('districts', 'District::index');
    $routes->get('districts/list', 'District::getDistrictList');
    $routes->add('district/add', 'District::add');
    $routes->post('district/delete/(:num)', 'District::delete/$1');
    $routes->add('district/counties/(:num)', 'District::counties/$1');

    $routes->get('counties', 'County::index');
    $routes->add('county/add', 'County::add');
    $routes->get('county/list', 'County::getCountyList');
    $routes->add('county/subcounties/(:num)', 'County::subcounties/$1');


    $routes->get('subcounties', 'Subcounty::index');
    $routes->get('subcounty/list', 'Subcounty::getSubcountyList');
    $routes->add('subcounty/parishes/(:num)', 'Subcounty::parishes/$1');

    $routes->get('parishes', 'Parish::index');
    $routes->get('parish/list', 'Parish::getParishList');
    $routes->add('parish/villages/(:num)', 'Parish::villages/$1');

    $routes->get('villages', 'Village::index');
    $routes->get('village/list', 'Village::getVillageList'); 
});