<?php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes = 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';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Pages::index');

$routes->get('/comics/create', 'comics::create');
$routes->get('/comics/edit/(:segment)', 'comics::edit/$1');
$routes->delete('/comics/(:num)', 'Comics::delete/$1');
$routes->get('/comics/(:any)', 'Comics::detail/$1');







// ================ CONTOH ========================
// ketika ada akses yg method request nya "get" atau ketika kita mengetikkan sesuatu di url, alamatnya adalah "/" atau "root" atau url utama, yaitu controller "Home" method "index"

// atau kita bisa membuat routes baru
// $routes->add('/coba', 'Coba::index'); //add bisa diganti dengan get juga.

// atau kita bisa memanggil fungsi langsung
// $routes->get('/coba', function(){
// 	echo "Hellow";
// });

// namun jika menggunakan routes dibawah method yg digantikan posisinya tidak akan mau dijalankan saat dipanggil di url, nah cara mengatasinya:
// $routes->get('/coba/index', 'Coba::index');
// $routes->get('/coba/about', 'Coba::about');

// memaksa alamat url dengan apapun untuk meenggantikan posisi method
// $routes->get('/coba/(:any)/(:num)', 'Coba::about/$1/$2');
// :any = apapun yg dikettiikan user
// :num = apapun yg angka
// :segment = apapun kecuali slice /
// :alpha = apapun yg alfabet
// :alphanum = apapun yg angka dan huruf, tidak termasuk karakter
// $1 akan mengambil placeholder yg pertama kali muncul, dari si :any

// setting urlnya seperti ini agar method file users di folder Admin bisa dijalankan
// $routes->get('/users', 'Admin\Users::index');
// ================ CONTOH ========================
/**
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
	require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
