<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use App\Services\Install\DBErpInstallStatus;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

final class EnsureDBErpIsInstalled
{
    public function handle(Request $request, Closure $next): Response
    {
        if (! app(DBErpInstallStatus::class)->isInstalled()) {
            return redirect()->route('install.welcome');
        }

        return $next($request);
    }
}
