<?php

declare(strict_types=1);

namespace Seka\Vzdelavanie;

use Illuminate\Support\Facades\Route;
use Elceka\Laravel\HashId\Facades\Hasher;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

/**
 * Class RouteServiceProvider
 *
 * @package Seka\Vzdelavanie
 */
final class RouteServiceProvider extends ServiceProvider
{
    /**
     *
     */
    public function boot()
    {
        parent::boot();

        Route::bind('vzdKnzncUcbnMtrlId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdKnzncSekciaId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdKnzncKategoriaId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdKnzncOtazkaId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdKnzncOdpovedId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdTstTstId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdTstOtzkId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdTstOdpvdId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdPzvtlKnzncOblbnId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdPzvtlTstTstId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdPzvtlTstOtzkId', function ($id) {
            return Hasher::decode($id);
        });

        Route::bind('vzdPzvtlTstOdpvdId', function ($id) {
            return Hasher::decode($id);
        });

        $this->routes();
    }

    /**
     *
     */
    protected function routes(): void
    {
        // BACKEND
        $this->loadRoutesFrom(__DIR__ . '/../routes/backend/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/backend/testy/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/backend/kniznica/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/backend/kniznica/api.php');

        // FRONTEND
        $this->loadRoutesFrom(__DIR__ . '/../routes/frontend/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/frontend/testy/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/frontend/kniznica/web.php');
        $this->loadRoutesFrom(__DIR__ . '/../routes/frontend/kniznica/api.php');
    }
}
