<?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('kniznica')
            ->name('kniznica.')
            ->namespace('Kniznica')
            ->middleware('permission:vzdelavanie|vzdelavanie_kniznica|vzdelavanie_kniznica.zobrazit')
            ->group(function () {
                Route::get('/', 'KniznicaController@index')->name('index');
                Route::prefix('ucebny-material/{vzdKnzncUcbnMtrlId}')->name('ucebnica.')->group(function () {
                    Route::get('/', 'UcebnicaController@show')->name('show');

                    Route::prefix('/sekcie')->name('sekcia.')->group(
                        function () {
                            Route::get('/', 'SekciaController@index')->name('index');
                            Route::get('/{vzdKnzncSekciaId}', 'SekciaController@show')->name('show');
                        }
                    );
                });

                Route::prefix('kategorie')->name('kategoria.')->group(function () {
                    Route::prefix('{vzdKnzncKategoriaId}/ucebny-material')->name('ucebnice.')->group(function () {
                        Route::get('/', 'KategoriaController@index')->name('index');
                        Route::post('/', 'KategoriaController@index')->name('filter');
                    });
                });
            });
    });
