99 rader
4.3 KiB
PHP
Blame Historik

<?php
namespace Config;
use CodeIgniter\Commands\Utilities\Routes;
// 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 (is_file(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();
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
//$routes->setAutoRoute(false);
/*
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Prestador::index', ['as' => 'home']);
$routes->get('horas/', 'Prestador::horas');
$routes->match(['get', 'post'], 'registro/', 'Prestador::formulario');
$routes->get('success', 'Prestador::success');
// ENCUESTAS
$routes->get('encuesta/answered', 'Encuesta::userAnswered');
$routes->get('encuesta/(:segment)', 'Encuesta::encuesta/$1', ['as' => 'encuesta']);
$routes->post('encuesta/submit/(:segment)', 'Encuesta::submit/$1', ['as' => 'encuesta_submit']);
// utilizar m<>todo attemptRegister personalizdo (no requiere de username)
$routes->post('register/', 'Auth::attemptRegister');
// $routes->post('login/', 'Auth::attemptLogin');
$routes->group('admin', ['filter' => 'role:Admin'], static function ($routes) {
$routes->get('/', 'Admin::home', ['as' => 'admin_home']);
// SOLICITUDES
$routes->get('solicitudes/', 'Admin::solicitudes', ['as' => 'admin_solicitudes']);
$routes->post('solicitud/rechazar/(:segment)', 'Admin::rechazarSolicitud/$1', ['as' => 'admin_solicitud_rechazar']);
$routes->get('solicitud/aprobar/(:segment)', 'Admin::aprobarSolicitud/$1', ['as' => 'admin_solicitud_aprobar']);
$routes->get('solicitud/(:segment)', 'Admin::revisarSolicitud/$1', ['as' => 'admin_solicitud_revisar']);
// ENCUESTAS
$routes->get('encuestas/', 'Admin::encuestas', ['as' => 'admin_encuestas']);
$routes->match(['get', 'post'], 'encuesta/nueva', 'Admin::nuevaEncuesta', ['as' => 'admin_encuesta_nueva']);
$routes->get('encuesta/(:segment)', 'Admin::encuesta/$1', ['as' => 'admin_encuesta']);
$routes->match(['get', 'post'], 'encuesta/editar/(:segment)', 'Admin::editarEncuesta/$1', ['as' => 'admin_encuesta_editar']);
$routes->get('encuesta/eliminar/(:segment)', 'Admin::eliminarEncuesta/$1', ['as' => 'admin_encuesta_eliminar']);
// PREGUNTAS
$routes->match(['get', 'post'], 'encuesta/(:segment)/pregunta/', 'Admin::nuevaPregunta/$1', ['as' => 'admin_pregunta_nueva']);
$routes->match(['get', 'post'], 'pregunta/editar/(:segment)', 'Admin::editarPregunta/$1', ['as' => 'admin_pregunta_editar']);
$routes->post('pregunta_post', 'Admin::preguntaPost', ['as' => 'pregunta_post']);
$routes->get('pregunta/eliminar/(:segment)', 'Admin::eliminarPregunta/$1', ['as' => 'admin_pregunta_eliminar']);
// GRUPOS
$routes->get('create_group/', 'Admin::createGroup');
});
/*
* --------------------------------------------------------------------
* 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 (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}