<?php

namespace App\Http\Middleware;

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

class EnsureApiCenterSchema
{
    public function handle(Request $request, Closure $next): Response
    {
        if (! app(ApiCenterSchema::class)->ready()) {
            return redirect()->route('admin.setup');
        }

        return $next($request);
    }
}
