<?php

use Illuminate\Support\Facades\Route;

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

                Route::namespace('Udalosti')
                    ->name('udalosti.')
                    ->prefix('udalosti')
                    ->middleware('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('permission:terminy.registracie.zobrazit')
                                    ->name('index');

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

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

                        Route::prefix('pracovisko/udalost/{mtUdalostId}')
                            ->middleware(['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');
                            });
                    });
            });
    });
