<?php

use Illuminate\Support\Facades\Route;

Route::prefix('terminy')
    ->middleware('web')
    ->namespace('Seka\Portal\Modul\Terminy\Http\Controllers')
    ->name('modul.terminy.')
    ->group(function () {
        Route::namespace('Frontend')
            ->name('frontend.')
            ->group(function () {
                Route::get('/', 'TerminyController@index')
                    ->middleware(['auth', 'permission:terminy.zobrazit'])
                    ->name('index');

                Route::namespace('Udalosti')
                    ->name('udalosti.')
                    ->prefix('udalosti')
                    ->middleware(['auth', 'permission:terminy.udalosti.zobrazit'])
                    ->group(function () {
                        Route::get('/', 'UdalostiController@index')->name('index');

                        Route::prefix('{mtUdalostId}')
                            ->name('udalost.')
                            ->group(function () {
                                Route::get('/', 'UdalostiController@show')
                                    ->name('show');
                                Route::get('/stiahnut', 'UdalostiController@eventCalendarFile')
                                    ->name('subor_kalendara');
                            });
                    });

                Route::namespace('Registracie')
                    ->prefix('registracie')
                    ->name('registracie.')
                    ->group(function () {
                        Route::prefix('pouzivatel')
                            ->name('pouzivatel.')
                            ->group(function () {
                                Route::get('/', 'PouzivatelController@index')
                                    ->middleware(['auth', 'permission:terminy.registracie.zobrazit'])
                                    ->name('index');

                                Route::prefix('udalost')
                                    ->group(function () {
                                        Route::post('{mtUdalostId}', 'PouzivatelController@create')
                                            ->middleware(['auth', 'permission:terminy.registracie.vytvorit'])
                                            ->name('create');

                                        Route::get('{mtUdalostId}/moznosti', 'PouzivatelController@selectOptions')
                                            ->middleware(['auth', 'permission:terminy.registracie.moznosti.vyber'])
                                            ->name('selectOptions');

                                        Route::delete('{mtUdalostId}', 'PouzivatelController@delete')
                                            ->middleware(['auth', 'permission:terminy.registracie.odstranit'])
                                            ->name('delete');
                                    });
                            });

                        Route::prefix('pracovisko/udalost/{mtUdalostId}')
                            ->middleware(['auth', 'role:spravca_pek', 'permission:terminy.registracie.zobrazit'])
                            ->name('pracovisko.')
                            ->group(function () {
                                Route::get('/', 'PracoviskoController@index')
                                    ->name('index');

                                Route::post('/', 'PracoviskoController@create')
                                    ->name('create');

                                Route::delete('/registracia/{mtRegistraciaId}', 'PracoviskoController@delete')
                                    ->name('delete');
                            });
                    });
            });
    });
