<?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('sprava')
    ->middleware('web')
    ->namespace('Seka\Vzdelavanie\Http\Controllers')
    ->name('vzdelavanie.')
    ->group(function () use ($path) {
        Route::prefix($path)->namespace('Backend')->middleware('permission:vzdelavanie')->name('sprava.')->group(function () {
            Route::prefix('testovanie')->namespace('Testovanie')->name('testovanie.')->group(function () {
                Route::get('/', 'TestovanieController@index')->name('index');

                // testy
                Route::prefix('testy')->name('testy.')->group(function () {
                    Route::get('/', 'TestController@index')->name('index');
                    Route::get('/novy', 'TestController@create')->name('create');
                    Route::post('/novy', 'TestController@store')->name('store');

                    Route::prefix('{vzdTstTstId}')->group(function () {
                        Route::get('/upravit', 'TestController@edit')->name('edit');
                        Route::put('/upravit', 'TestController@update')->name('update');
                        Route::delete('/odstranit', 'TestController@destroy')->name('destroy');

                        // otazky
                        Route::prefix('otazky')->name('otazky.')->group(function () {
                            Route::get('/', 'TestOtazkyController@index')->name('index');
                            Route::get('/nova', 'TestOtazkyController@create')->name('create');
                            Route::post('/nova', 'TestOtazkyController@store')->name('store');

                            Route::prefix('{vzdTstOtzkId}')->group(function () {
                                Route::get('/upravit', 'TestOtazkyController@edit')->name('edit');
                                Route::put('/upravit', 'TestOtazkyController@update')->name('update');
                                Route::delete('/odstranit', 'TestOtazkyController@destroy')->name('destroy');

                                // odpovede
                                Route::prefix('odpovede')->name('odpovede.')->group(function () {
                                    Route::get('/', 'TestOtazkyOdpovedeController@index')->name('index');
                                    Route::get('/nova', 'TestOtazkyOdpovedeController@create')->name('create');
                                    Route::post('/nova', 'TestOtazkyOdpovedeController@store')->name('store');

                                    Route::prefix('{vzdTstOdpvdId}')->group(function () {
                                        Route::get('/upravit', 'TestOtazkyOdpovedeController@edit')->name('edit');
                                        Route::put('/upravit', 'TestOtazkyOdpovedeController@update')->name('update');
                                        Route::delete('/odstranit', 'TestOtazkyOdpovedeController@destroy')->name('destroy');
                                    });
                                });
                            });
                        });
                    });
                });

                // pouzivatelia
                Route::prefix('pouzivatelia')->name('pouzivatelia.')->group(function () {
                    Route::get('/', 'PouzivatelController@index')->name('index');
                });
            });
        });
    }
);
