<?php

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

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

echo "=== ImmigoPro Subscriptions ===\n\n";

$subscriptions = App\Models\ImmigoProSubscription::with('user')->get();

if ($subscriptions->count() === 0) {
    echo "No ImmigoPro subscriptions found.\n";
} else {
    foreach ($subscriptions as $sub) {
        echo "ID: {$sub->id}\n";
        echo "  User: {$sub->user->name} (ID: {$sub->user_id})\n";
        echo "  Package: {$sub->package_name}\n";
        echo "  Payment Plan: {$sub->payment_plan}\n";
        echo "  Status: {$sub->status}\n";
        echo "  Installments: {$sub->paid_installments}/{$sub->installments}\n";
        echo "  Total Amount: \${$sub->total_amount}\n";
        echo "  Next Charge: " . ($sub->next_charge_date ?? 'N/A') . "\n";
        echo "  Created: {$sub->created_at}\n";
        echo "\n";
    }
}

echo "\n=== ImmigoPro Installment Payments ===\n\n";

$payments = App\Models\ImmigoProInstallmentPayment::with('subscription.user')->get();

if ($payments->count() === 0) {
    echo "No installment payments found.\n";
} else {
    foreach ($payments as $payment) {
        echo "Payment ID: {$payment->id}\n";
        echo "  Subscription: #{$payment->subscription_id} - {$payment->subscription->package_name}\n";
        echo "  User: {$payment->subscription->user->name}\n";
        echo "  Installment: #{$payment->installment_number}\n";
        echo "  Amount: \${$payment->amount}\n";
        echo "  Status: {$payment->status}\n";
        echo "  Paid At: {$payment->paid_at}\n";
        echo "\n";
    }
}
