<?php

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

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

$card_publicitarios = CardPublicitario::mdlGetAllCardsPublicitarios();

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

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

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

echo json_encode($response);
