<?php
    // HEADERS
    header('Access-Control-Allow-Origin: *');
    header('Content-Type: application/json');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    include_once '../../config/Database.php';
    include_once '../../models/Posicao.php';

    // INSTANTIATE DB AND CONNECT
    $database = new Database();
    $db = $database->connect();

    // INSTANTIATE POST OBJECT
    $posicao = new Posicao($db);

    // GET ID
    $posicao->id = isset($_GET['id']) ? $_GET['id'] : die();

    // GET POST
    $posicao->read_single();

    // CREATE ARRAY
    $posicao_arr = array(
        'id' => $posicao->id,
        'produtoPosicao' => $posicao->produtoPosicao
    );

    // MAKE JSON
    print_r(json_encode($posicao_arr));
}