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

$users = \App\Models\User::all();
echo "Total users: " . $users->count() . "\n\n";
foreach ($users as $u) {
    echo "ID: {$u->id} | Email: {$u->email} | Name: {$u->name}\n";
    echo "  Password matches 'password123': " . (\Illuminate\Support\Facades\Hash::check('password123', $u->password) ? 'YES' : 'NO') . "\n";
    echo "  Password matches 'password': " . (\Illuminate\Support\Facades\Hash::check('password', $u->password) ? 'YES' : 'NO') . "\n";
    // Check columns
    $cols = array_keys($u->getAttributes());
    $roleRelated = array_filter($cols, fn($c) => str_contains($c, 'role') || str_contains($c, 'admin') || str_contains($c, 'type'));
    foreach ($roleRelated as $col) {
        echo "  {$col}: {$u->$col}\n";
    }
    echo "\n";
}

// Check User model canAccessPanel method
echo "\n--- Checking canAccessPanel ---\n";
$user = $users->first();
if ($user && method_exists($user, 'canAccessPanel')) {
    try {
        $panel = \Filament\Facades\Filament::getPanel('admin');
        echo "canAccessPanel: " . ($user->canAccessPanel($panel) ? 'YES' : 'NO') . "\n";
    } catch (\Throwable $e) {
        echo "Error: " . $e->getMessage() . "\n";
    }
} else {
    echo "No canAccessPanel method or no user\n";
}
