<?php

require_once __DIR__ . '/../vendor/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();

use App\Models\Withdrawal;

echo "====== VÉRIFICATION PAYMENT_DETAILS ======\n\n";

$withdrawals = Withdrawal::latest()->take(5)->get();

if ($withdrawals->isEmpty()) {
    echo "Aucun retrait en base.\n";
} else {
    foreach ($withdrawals as $w) {
        echo "ID: {$w->id}\n";
        echo "Référence: {$w->reference}\n";
        echo "Méthode: {$w->payment_method}\n";
        echo "Montant: " . number_format($w->amount, 0, ',', ' ') . " XOF\n";
        echo "Status: {$w->status}\n";
        echo "Payment Details (raw): " . json_encode($w->payment_details) . "\n";
        
        if ($w->payment_details) {
            echo "Payment Details (parsed):\n";
            foreach ($w->payment_details as $key => $value) {
                echo "  - {$key}: {$value}\n";
            }
        } else {
            echo "Payment Details: VIDE\n";
        }
        
        echo str_repeat("-", 50) . "\n";
    }
}

echo "\n====== FIN ======\n";
