<?php

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

use Illuminate\Support\Facades\DB;

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

echo "Portal Dashboard Visibility Status\n";
echo str_repeat('=', 120) . "\n\n";

$portals = DB::table('portals')
    ->select('id', 'name', 'key', 'enabled', 'show_in_user_dashboard', 'url')
    ->orderBy('name')
    ->get();

echo sprintf("%-5s | %-35s | %-25s | %-10s | %-20s | %s\n", 
    'ID', 'Name', 'Key', 'Enabled', 'Show in Dashboard', 'Will Display?');
echo str_repeat('-', 120) . "\n";

foreach ($portals as $portal) {
    $willDisplay = ($portal->enabled && $portal->show_in_user_dashboard) ? '✓ YES' : '✗ NO';
    
    echo sprintf("%-5s | %-35s | %-25s | %-10s | %-20s | %s\n",
        $portal->id,
        $portal->name,
        $portal->key,
        $portal->enabled ? 'true' : 'false',
        $portal->show_in_user_dashboard ? 'true' : 'false',
        $willDisplay
    );
}

echo str_repeat('-', 120) . "\n\n";

$visibleCount = DB::table('portals')
    ->where('enabled', true)
    ->where('show_in_user_dashboard', true)
    ->count();

echo "Summary:\n";
echo "  Total portals: " . count($portals) . "\n";
echo "  Will be displayed on user dashboard: " . $visibleCount . "\n\n";

echo "Note: Portals must have BOTH 'enabled' = true AND 'show_in_user_dashboard' = true to appear on user dashboard.\n";
