<?php

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

$provider_id = ProviderAuth::id();

$data = Request::post();

try{

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

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


/*
-----------------------------------
DELETE SERVICE AREA
-----------------------------------
*/

$stmt=$conn->prepare("

DELETE FROM provider_service_area_map

WHERE id=:id
AND provider_id=:provider

");

$stmt->execute([

':id'=>$data['id'],
':provider'=>$provider_id

]);

Response::success([],"Service area removed");

}
catch(Exception $e){

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

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

}