<?php

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

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

echo "=== Checking Pengawas Data ===\n\n";

// Check role
$role = Role::where('slug', 'pengawas')->first();
echo "Role Pengawas: ";
if ($role) {
    echo "ID: {$role->id}, Name: {$role->name}\n";
} else {
    echo "NOT FOUND!\n";
}

// Check users with pengawas role
if ($role) {
    $count = User::where('role_id', $role->id)->count();
    echo "\nTotal Users with Pengawas Role: {$count}\n";
    
    if ($count > 0) {
        echo "\nPengawas Users:\n";
        $users = User::where('role_id', $role->id)->get();
        foreach ($users as $user) {
            echo "- ID: {$user->id}, Name: {$user->name}, Email: {$user->email}, KCD: {$user->kcd_id}\n";
        }
    }
}

// Check current logged in user (assuming superadmin with ID 1)
echo "\n=== Checking Logged in User ===\n";
$admin = User::find(1);
if ($admin) {
    echo "Admin: {$admin->name}, Role: {$admin->role->name}, KCD: {$admin->kcd_id}\n";
}
