<?php

declare(strict_types=1);

namespace Seka\Terminy;

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

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

        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);
        });

        $this->routes();
    }

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

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