<?php
/**
 * Created by PhpStorm.
 * User: radko
 * Date: 13.11.18
 * Time: 8:11
 */

use Illuminate\Support\Facades\Route;
use Seka\Vzdelavanie\Http\Controllers\Frontend\Testovanie\PouzivatelTestController;
use Seka\Vzdelavanie\Http\Controllers\Frontend\Testovanie\TestController;

if ($domain = config('vzdelavanie.subdomena')) {
    $domain = sprintf(
        '%s.%s',
        $domain,
        config('app.domain')
    );
}

$path = config('vzdelavanie.cesta');

Route::domain($domain)
    ->prefix($path)
    ->middleware(['web', 'auth', 'permission:vzdelavanie|vzdelavanie_kniznica|vzdelavanie_testovanie.zobrazit'])
    ->name('vzdelavanie.')
    ->group(function () {
        Route::prefix('testy')
            ->name('testy.')
            ->group(function () {
                Route::get('/', [TestController::class, 'index'])
                    ->name('index');

                Route::get('/zoznam', [TestController::class, 'zoznamTestov'])
                    ->name('zoznam');

                Route::prefix('pouzivatela')
                    ->name('pouzivatela.')
                    ->group(function () {
                        Route::get('/', [PouzivatelTestController::class, 'historia'])
                            ->name('historia');

                        Route::get('/graf', [PouzivatelTestController::class, 'graf'])
                            ->name('graf');

                        Route::prefix('test')
                            ->name('test.')
                            ->group(function () {
                                Route::post('/generovanie/{vzdTstTstId}', [PouzivatelTestController::class, 'generovanie'])
                                    ->name('generovanie');

                                Route::prefix('{vzdPzvtlTstTstId}')
                                    ->group(function () {
                                        Route::get('/', [PouzivatelTestController::class, 'spustenie'])
                                            ->name('spustenie');

                                        Route::patch('/', [PouzivatelTestController::class, 'vyhodnotit'])
                                            ->name('vyhodnotit');

                                        Route::get('/vyhodnotenie', [PouzivatelTestController::class, 'vyhodnotenie'])
                                            ->name('vyhodnotenie');
                                    });
                            });
                    });
            });
    });
