<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

require '../../modelo/banner.php';
require '../../modelo/environment.php';
$response = array();

$banners = Banner::mdlGetBanners();

if (!$banners) {
    $response['response'] = 'error';
    $response['message'] = 'No se encontraron banners';
    echo json_encode($response);
    return;
}

foreach ($banners as $key => $banner) {
    $banners[$key]['url_imagen'] = Environment::getUrlServidor() . $banner['url_imagen'];
}

$response['response'] = 'success';
$response['data'] = $banners;

echo json_encode($response);
