<?php

require __DIR__ . '/vendor/autoload.php';

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

use App\Models\ImmigoProSubscription;

echo "=== Checking Split Payment Subscriptions ===\n\n";

// Find all split payment subscriptions
$subscriptions = ImmigoProSubscription::where('payment_plan', 'split')
    ->orderBy('created_at', 'desc')
    ->get();

if ($subscriptions->isEmpty()) {
    echo "No split payment subscriptions found.\n";
    exit;
}

foreach ($subscriptions as $sub) {
    echo "Subscription ID: {$sub->id}\n";
    echo "User ID: {$sub->user_id}\n";
    echo "Package ID: {$sub->immigopro_package_id}\n";
    echo "Payment Plan: {$sub->payment_plan}\n";
    echo "Status: {$sub->status}\n";
    echo "Total Amount: \${$sub->total_amount}\n";
    echo "Upfront Amount: \${$sub->upfront_amount}\n";
    echo "Monthly Amount: \${$sub->monthly_amount}\n";
    echo "Installments: {$sub->installments}\n";
    echo "Paid Installments: {$sub->paid_installments}\n";
    echo "Next Charge Date: " . ($sub->next_charge_date ?? 'NULL') . "\n";
    echo "Created At: {$sub->created_at}\n";
    echo "Updated At: {$sub->updated_at}\n";
    echo "\n" . str_repeat('-', 50) . "\n\n";
}
