<?php

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

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

use App\Models\Invoice;
use App\Models\Subscription;

echo "=== Checking Invoices ===\n\n";

$invoices = Invoice::with('transactions')->get();
echo "Total invoices: " . $invoices->count() . "\n\n";

foreach($invoices as $invoice) {
    echo "Invoice #" . $invoice->invoice_number . "\n";
    echo "  User ID: " . $invoice->user_id . "\n";
    echo "  Amount: " . $invoice->amount . " " . $invoice->currency . "\n";
    echo "  Status: " . $invoice->status . "\n";
    echo "  Created: " . $invoice->created_at . "\n";
    echo "  Transactions: " . $invoice->transactions->count() . "\n";
    echo "\n";
}

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

$subscriptions = Subscription::all();
echo "Total subscriptions: " . $subscriptions->count() . "\n\n";

foreach($subscriptions as $sub) {
    echo "Subscription ID: " . $sub->id . "\n";
    echo "  User ID: " . $sub->user_id . "\n";
    echo "  Package: " . $sub->package_name . "\n";
    echo "  Status: " . $sub->status . "\n";
    echo "  Created: " . $sub->created_at . "\n";
    echo "\n";
}
