<?php

namespace Modules\VrcPortalApi\Providers;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\VrcPortalApi\Http\Middleware\OwnerApiAuth;
use Modules\VrcPortalApi\Http\Middleware\ResolveVrcConnection;
use Modules\VrcPortalApi\Http\Middleware\StaffApiAuth;

class VrcPortalApiServiceProvider extends ServiceProvider
{
    public function boot(Router $router): void
    {
        $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'vrcPortalApi');
        $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');

        $router->aliasMiddleware('vrc-portal.connection', ResolveVrcConnection::class);
        $router->aliasMiddleware('vrc-portal.owner', OwnerApiAuth::class);
        $router->aliasMiddleware('vrc-portal.staff', StaffApiAuth::class);
    }

    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../Config/config.php', 'vrcportalapi');
        $this->app->register(RouteServiceProvider::class);
    }
}
