<?php

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

use App\Models\Portal;

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

echo "Portal Order Test\n";
echo str_repeat('=', 80) . "\n\n";

$portals = Portal::orderBy('order')->orderBy('name')->get();

echo "Current Portal Order:\n";
echo str_repeat('-', 80) . "\n";
printf("%-6s | %-8s | %-35s | %-20s\n", 'Order', 'ID', 'Name', 'Key');
echo str_repeat('-', 80) . "\n";

foreach ($portals as $portal) {
    printf("%-6s | %-8s | %-35s | %-20s\n", 
        $portal->order,
        $portal->id,
        $portal->name,
        $portal->key
    );
}

echo str_repeat('-', 80) . "\n";
echo "\nNote: Drag and drop rows in the Portal Management table to reorder.\n";
echo "The order will be saved automatically to the database.\n";
