<?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'])
    ->namespace('Seka\Vzdelavanie\Http\Controllers')
    ->name('vzdelavanie.')
    ->group(function () {
        Route::prefix('sprava')
            ->namespace('Backend')
            ->name('sprava.')
            ->group(function () {
                Route::prefix('kniznica')
                    ->name('kniznica.')
                    ->namespace('Kniznica')
                    ->group(function () {
                        Route::get('/', 'KniznicaController@index')->name('index');

                        Route::prefix('kategorie')
                            ->name('kategoria.')
                            ->group(function () {
                                Route::get('/', 'KategoriaController@index')
                                    ->name('index');

                                Route::get('/nova', 'KategoriaController@create')
                                    ->name('create');

                                Route::post('/nova', 'KategoriaController@store')
                                    ->name('store');

                                Route::prefix('{vzdKnzncKategoriaId}')
                                    ->group(function () {
                                        Route::get('/upravit', 'KategoriaController@edit')
                                            ->name('edit');

                                        Route::put('/upravit', 'KategoriaController@update')
                                            ->name('update');

                                        Route::delete('/odstranit', 'KategoriaController@destroy')
                                            ->name('destroy');

                                        Route::prefix('/ucebny-material')
                                            ->name('ucebnice.')
                                            ->group(function () {
                                                Route::get('/', 'UcebnicaController@index')
                                                    ->name('index');

                                                Route::post('/', 'UcebnicaController@index')
                                                    ->name('filter');

                                                Route::get('/novy', 'UcebnicaController@create')
                                                    ->name('create');

                                                Route::post('/novy', 'UcebnicaController@store')
                                                    ->name('store');

                                                Route::prefix('{vzdKnzncUcbnMtrlId}')
                                                    ->group(function () {
                                                        Route::get('/upravit', 'UcebnicaController@edit')
                                                            ->name('edit');

                                                        Route::put('/upravit', 'UcebnicaController@update')
                                                            ->name('update');

                                                        Route::delete('/odstranit', 'UcebnicaController@destroy')
                                                            ->name('destroy');

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

                                                                Route::get('/nova', 'SekciaController@create')
                                                                    ->name('create');

                                                                Route::post('/nova', 'SekciaController@store')
                                                                    ->name('store');

                                                                Route::prefix('{vzdKnzncSekciaId}')
                                                                    ->group(function () {
                                                                        Route::get('/upravit', 'SekciaController@edit')
                                                                            ->name('edit');

                                                                        Route::put('/upravit', 'SekciaController@update')
                                                                            ->name('update');

                                                                        Route::delete('/odstranit', 'SekciaController@destroy')
                                                                            ->name('destroy');
                                                                    });
                                                            });
                                                    });
                                            });
                                    });
                            });
                    });
            });
    });
