<?php

namespace App\Http\Helpers;

use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class CloudflareHelper
{
    public static function setIUAM($mode)
{
    $zones = [
        config('services.cloudflare.zone_id_1'),
        config('services.cloudflare.zone_id_2'),
    ];

    foreach ($zones as $zoneId) {
        $response = Http::withToken(config('services.cloudflare.token'))
            ->patch("https://api.cloudflare.com/client/v4/zones/{$zoneId}/settings/security_level", [
                'value' => $mode,
            ]);

        if ($response->successful()) {
        $message = "Under Attack Mode Enabled via API \n";
        $chatId = '-4734079928';
        sendTelegramNotify($message,$chatId);
        }
    }

    return true;
}
}

 