<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Blocks the install wizard once `storage/installed.lock` exists. Returns
 * 404 so a curious visitor on a fully-installed site can't even tell the
 * wizard ever existed — re-running it would clobber DB credentials.
 */
class GuardInstaller
{
    public function handle(Request $request, Closure $next): Response
    {
        if (file_exists(storage_path('installed.lock'))) {
            abort(404);
        }

        return $next($request);
    }
}
