<?php

namespace App\Controllers;

use App\Models\Client;
use App\Models\Server;
use App\Models\Order;
use App\Models\Domain;
use App\Utils\View;

class AdminDashboardController
{
    public function index()
    {
        $clientModel = new Client();
        $serverModel = new Server();
        $orderModel = new Order();
        $domainModel = new Domain();

        $stats = [
            'clients' => count($clientModel->where('status', 'active')),
            'servers' => count($serverModel->where('status', 'active')),
            'orders' => count($orderModel->findAll()),
            'blocked_domains' => $domainModel->countBlocked()
        ];

        $recent_orders = $orderModel->recent(5);

        View::render('layouts.admin', [
            'title' => 'Dashboard',
            'content' => __DIR__ . '/../../resources/views/admin/dashboard.php',
            'stats' => $stats,
            'recent_orders' => $recent_orders
        ]);
    }
}
