<?php
require_once '../../config/database.php';
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');

try {
    $db = Database::getInstance()->getConnection();
    
    $stmt = $db->query("SELECT * FROM banners WHERE ativo = 1 ORDER BY ordem ASC LIMIT 4");
    $banners = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo json_encode(['success' => true, 'banners' => $banners]);
    
} catch (Exception $e) {
    echo json_encode(['success' => true, 'banners' => []]);
}