<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Credentials: true");
header('Content-Type: application/json');
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/destination.php';
 
// get database connection
$database = new Database();
$db = $database->getConnection();
 
// prepare product object
$Destination = new Destination($db);
 
// set Id property of record to read
$Destination->Id = isset($_GET['Id']) ? $_GET['Id'] : die();
 
// read the details of product to be edited
$Destination->readOne();
 
if($Destination->Name!=null){
    // create array
    $Destination_arr = array(
        "Id" =>  $Destination->Id, 
        "countryId" =>  $Destination->countryId, 
        "Name" => $Destination->Name,
        "Description" => $Destination->Description,
        "Recommended" => $Destination->Recommended
    );
 
    // set response code - 200 OK
    http_response_code(200);
 
    // make it json format
    echo json_encode($Destination_arr);
}
 
else{
    // set response code - 404 Not found
    http_response_code(404);
 
    // tell the user product does not exist
    echo json_encode(array("message" => "Destination does not exist."));
}
?>