<?php

use Illuminate\Support\Facades\Route;

Route::namespace('App\Http\Controllers')
    ->name('portal.')
    ->group(function () {
        Route::prefix('sprava')
            ->namespace('Backend')
            ->middleware('role_or_permission:admin|portal_sprava')
            ->name('sprava.')
            ->group(function () {
                Route::get('/', 'SpravaController@index')->name('index');

                Route::prefix('pouzivatelia')
                    ->namespace('Pouzivatelia')
                    ->middleware('permission:portal_sprava_pouzivatelia')
                    ->name('pouzivatelia.')
                    ->group(function () {
                        Route::get('/', 'PouzivateliaController@index')->name('index');

                        Route::prefix('{pouzivatelId}')
                            ->group(function () {
                                Route::get('/upravit', 'PouzivateliaController@edit')->name('edit');
                                Route::put('/upravit', 'PouzivateliaController@update')
                                    ->middleware('role:admin')
                                    ->name('update');

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

                                Route::prefix('notifications')
                                    ->name('notifications.send')
                                    ->middleware('role:admin')
                                    ->post('/', 'PouzivateliaController@send');
                            });
                    });

                Route::prefix('informacie')
                    ->namespace('Informacie')
                    ->name('informacie.')
                    ->group(function () {
                        Route::get('/', 'ShowIndexPage')->name('index');
                        Route::get('/vytvorit', 'ShowCreatePage')->name('create');
                        Route::prefix('{informaciaId}')
                            ->group(function () {
                                Route::get('/upravit', 'ShowEditPage')->name('edit');
                            });
                    });

                Route::prefix('moduly')
                    ->namespace('Moduly')
                    ->name('moduly.')
                    ->group(function () {
                        Route::get('/', 'ZoznamController')->name('index');
                    });
            });
    });
