<?php

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

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

// Get user 28
$user = \App\Models\User::find(28);
echo "User: " . $user->email . "\n";
echo "Has marketing_officer role: " . ($user->hasRole('marketing_officer') ? 'Yes' : 'No') . "\n";

// Check assignments
$assignments = \DB::table('marketing_officer_users')
    ->where('marketing_officer_id', 28)
    ->get();
    
echo "\nAssignments count: " . $assignments->count() . "\n";
echo "Assignments: " . json_encode($assignments, JSON_PRETTY_PRINT) . "\n";

// Get assigned user IDs
$assignedUserIds = \DB::table('marketing_officer_users')
    ->where('marketing_officer_id', 28)
    ->pluck('user_id')
    ->toArray();
    
echo "\nAssigned User IDs: " . json_encode($assignedUserIds) . "\n";

// Get user details
$users = \App\Models\User::whereIn('id', $assignedUserIds)
    ->get(['id', 'name', 'email', 'status']);
    
echo "\nAssigned Users: " . json_encode($users, JSON_PRETTY_PRINT) . "\n";
