<?php

define('LARAVEL_START', microtime(true));
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

use App\Models\User;
use App\Models\Role;

echo "--- ADMIN USERS ---\n";
try {
    $admins = User::whereHas('role', function($q) { $q->where('name', 'admin'); })->get();
    foreach($admins as $a) {
        echo "ID:{$a->id} | Email:{$a->email} | Status:{$a->account_status}\n";
    }
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

echo "\n--- LEASING USERS ---\n";
try {
    $leasings = User::whereHas('role', function($q) { $q->where('name', 'leasing'); })->get();
    foreach($leasings as $l) {
        echo "ID:{$l->id} | Email:{$l->email} | Status:{$l->account_status} | Profiles: " . $l->leasingProfile()->count() . "\n";
    }
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
