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

use Illuminate\Support\Facades\Route;

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'])
    ->namespace('Seka\Vzdelavanie\Http\Controllers\Frontend')
    ->name('vzdelavanie.')
    ->group(function () {
        Route::prefix('testy')
            ->name('testy.')
            ->namespace('Testovanie')
            ->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::get('/graf', 'PouzivatelTestController@graf')
                            ->name('graf');

                        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');
                                    });
                            });
                    });
            });
    });
