<?php

namespace App\Http\Middleware;

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

class CheckMaintenance
{
    public function handle(Request $request, Closure $next): Response
    {
        if (app()->isDownForMaintenance()) {
            return response()->json([
                'success' => false,
                'message' => 'Layanan sedang dalam pemeliharaan. Silakan coba beberapa saat lagi.',
            ], 503);
        }

        return $next($request);
    }
}
