<?php

use App\Http\Controllers\Backend;
use Illuminate\Support\Facades\Route;

Route::name('portal.')
    ->group(function () {
        Route::prefix('sprava')
            ->middleware('role_or_permission:admin|portal_sprava')
            ->name('sprava.')
            ->group(function () {
                Route::get('/', [Backend\SpravaController::class, 'index'])->name('index');

                Route::prefix('pouzivatelia')
                    ->middleware('permission:portal_sprava_pouzivatelia')
                    ->name('pouzivatelia.')
                    ->group(function () {
                        Route::get('/', [Backend\Pouzivatelia\PouzivateliaController::class, 'index'])->name('index');

                        Route::prefix('{pouzivatelId}')
                            ->group(function () {
                                Route::get('/upravit', [Backend\Pouzivatelia\PouzivateliaController::class, 'edit'])->name('edit');
                                Route::put('/upravit', [Backend\Pouzivatelia\PouzivateliaController::class, 'update'])
                                    ->middleware('role:admin')
                                    ->name('update');

                                Route::prefix('akcie')->name('akcie.')->group(function () {
                                    Route::get('/', [Backend\Pouzivatelia\AkciePouzivatelovController::class, 'index'])->name('index');
                                });

                                Route::prefix('notifications')
                                    ->name('notifications.send')
                                    ->middleware('role:admin')
                                    ->post('/', [Backend\Pouzivatelia\PouzivateliaController::class, 'send']);
                            });
                    });

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

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