<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Providers;

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

/**
 * Class RouteServiceProvider
 *
 * @package Seka\Portal\Modul\Terminy\Providers
 */
final class RouteServiceProvider extends ServiceProvider
{
    /**
     *
     */
    public function boot(): void
    {
        Route::bind('mtUdalostId', function ($hashId) {
            return Hasher::decode($hashId);
        });

        Route::bind('mtRegistraciaId', function ($hashId) {
            return Hasher::decode($hashId);
        });

        Route::bind('mtMiestoKonaniaId', function ($hashId) {
            return Hasher::decode($hashId);
        });

        Route::bind('mtMoznostUdalostiId', function ($hashId) {
            return Hasher::decode($hashId);
        });

        $this->routes(function () {
            // BACKEND
            $this->loadRoutesFrom(__DIR__ . '/../Routes/backend/web.php');

            // FRONTEND
            $this->loadRoutesFrom(__DIR__ . '/../Routes/frontend/web.php');
        });
    }
}
