<?php

use kernel\App;
use kernel\CgRouteCollector;
use Phroute\Phroute\RouteCollector;

App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) {
    App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
        App::$collector->group(["prefix" => "card"], function (CGRouteCollector $router) {
            App::$collector->get('/', [\app\modules\card\controllers\CardController::class, 'actionIndex']);
            App::$collector->get('/page/{page_number}', [\app\modules\card\controllers\CardController::class, 'actionIndex']);
            App::$collector->get('/create', [\app\modules\card\controllers\CardController::class, 'actionCreate']);
            App::$collector->post("/", [\app\modules\card\controllers\CardController::class, 'actionAdd']);
            App::$collector->get('/{id}', [\app\modules\card\controllers\CardController::class, 'actionView']);
            App::$collector->any('/update/{id}', [\app\modules\card\controllers\CardController::class, 'actionUpdate']);
            App::$collector->any("/edit/{id}", [\app\modules\card\controllers\CardController::class, 'actionEdit']);
            App::$collector->get('/delete/{id}', [\app\modules\card\controllers\CardController::class, 'actionDelete']);
        });
    });
});

App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) {
    App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
        App::$collector->group(["prefix" => "card_template"], function (CGRouteCollector $router) {
            App::$collector->get('/', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionIndex']);
            App::$collector->get('/page/{page_number}', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionIndex']);
            App::$collector->get('/create', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionCreate']);
            App::$collector->post("/", [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionAdd']);
            App::$collector->get('/{id}', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionView']);
            App::$collector->any('/update/{id}', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionUpdate']);
            App::$collector->any("/edit/{id}", [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionEdit']);
            App::$collector->get('/delete/{id}', [\kernel\app_modules\card\controllers\CardTemplateController::class, 'actionDelete']);
        });
    });
});

App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
    App::$collector->group(['before' => 'bearer'], function (CgRouteCollector $router){
        $router->rest("card", [\kernel\app_modules\card\controllers\CardRestController::class]);
    });
});