<?php

namespace App\Http\Middleware;

use App\Support\Installation;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

/** Hides the installer the moment the system is installed. */
class EnsureInstallerIsAvailable
{
    public function handle(Request $request, Closure $next): Response
    {
        if (Installation::isInstalled() && ! $request->routeIs('install.done')) {
            abort(404);
        }

        return $next($request);
    }
}
