<?php

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

ProviderAuth::id();

$data = Request::get();

try {

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

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

$query="

SELECT
id,
name

FROM cities

WHERE state_id=:state_id
AND status=1

ORDER BY name ASC

";

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

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

$rows=$stmt->fetchAll();

Response::success($rows);

}
catch(Exception $e){

Logger::log("system.log",$e->getMessage());
Response::error("Server error",500);

}