<?php

require_once '../../core/api_bootstrap.php';

$data = Request::get();

try {

Validator::required($data,['city_id']);

$db = new Database();
$conn = $db->connect();

$query = "

SELECT
id,
pincode,
area_name

FROM pincodes

WHERE city_id = :city_id
AND status = 1

ORDER BY area_name ASC

";

$stmt = $conn->prepare($query);

$stmt->execute([
':city_id'=>$data['city_id']
]);

$rows = $stmt->fetchAll();

Response::success($rows);

}
catch(Exception $e){

Logger::log("system.log",$e->getMessage());

Response::error("Server error",500);

}