<?php

declare(strict_types=1);

namespace App\Providers;

use App\Http\Middleware\IdentifyTenant;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;

class TenancyServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        //
    }

    public function boot(): void
    {
        /** @var Router $router */
        $router = $this->app['router'];
        $router->aliasMiddleware('tenant', IdentifyTenant::class);

        // Apply to "api" group automatically.
        $router->pushMiddlewareToGroup('api', IdentifyTenant::class);
    }
}
