<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Providers;

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

/**
 * 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');
        });
    }
}
