<?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/Categoria.php';

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

    // INSTANTIATE POST OBJECT
    $categoria = new Categoria($db);

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

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

    // CREATE ARRAY
    $categoria_arr = array(
        'id' => $categoria->id,
        'produtoCategoria' => $categoria->produtoCategoria
    );

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