<?php

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

$app = require_once __DIR__ . '/../../bootstrap/app.php';

// Bootstrap the application (so facades, config, DB work)
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

try {
    $export = new App\Exports\InvoiceItemsReportExport([]);
    $collection = $export->collection();
    echo "OK: rows=" . ($collection instanceof \Illuminate\Support\Collection ? $collection->count() : 0) . PHP_EOL;
    // print first row as example
    if ($collection instanceof \Illuminate\Support\Collection && $collection->count() > 0) {
        print_r($collection->first());
    }
} catch (Exception $e) {
    echo "EXCEPTION: " . get_class($e) . " - " . $e->getMessage() . PHP_EOL;
    echo $e->getTraceAsString();
}
