<?php

/**
 * Roles & Permissions module routes.
 * @var \CodeIgniter\Router\RouteCollection $routes
 */
$routes->group('roles', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Roles\Controllers\RoleController::index', ['filter' => 'permission:roles.view']);
    $routes->get('create', '\Modules\Roles\Controllers\RoleController::createForm', ['filter' => 'permission:roles.create']);
    $routes->post('/', '\Modules\Roles\Controllers\RoleController::store', ['filter' => 'permission:roles.create']);
    $routes->get('(:num)/edit', '\Modules\Roles\Controllers\RoleController::editForm/$1', ['filter' => 'permission:roles.edit']);
    $routes->post('(:num)', '\Modules\Roles\Controllers\RoleController::update/$1', ['filter' => 'permission:roles.edit']);
    $routes->post('(:num)/permissions', '\Modules\Roles\Controllers\RoleController::updatePermissions/$1', ['filter' => 'permission:roles.edit']);
    $routes->post('(:num)/delete', '\Modules\Roles\Controllers\RoleController::destroy/$1', ['filter' => 'permission:roles.delete']);
});

$routes->group('permissions', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', '\Modules\Roles\Controllers\PermissionController::index', ['filter' => 'permission:permissions.view']);
    $routes->post('/', '\Modules\Roles\Controllers\PermissionController::store', ['filter' => 'permission:permissions.create']);
    $routes->post('(:num)/delete', '\Modules\Roles\Controllers\PermissionController::destroy/$1', ['filter' => 'permission:permissions.delete']);
});
