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

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

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

Route::domain($domain)
    ->prefix($path)
    ->middleware('web')
    ->namespace('Seka\Vzdelavanie\Http\Controllers\Frontend')
    ->name('vzdelavanie.')
    ->group(function () {
        Route::prefix('testy')
            ->name('testy.')
            ->namespace('Testovanie')
            ->middleware('permission:vzdelavanie|vzdelavanie_kniznica|vzdelavanie_testovanie.zobrazit')
            ->group(function () {
                Route::get('/', 'TestController@index')->name('index');
                Route::get('/zoznam', 'TestController@zoznamTestov')->name('zoznam');

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

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

                        Route::prefix('{vzdPzvtlTstTstId}')->group(function () {
                            Route::get('/', 'PouzivatelTestController@spustenie')->name('spustenie');
                            Route::patch('/', 'PouzivatelTestController@vyhodnotit')->name('vyhodnotit');
                            Route::get('/vyhodnotenie', 'PouzivatelTestController@vyhodnotenie')->name('vyhodnotenie');
                        });
                    });
                });
            });
    });
