<?php

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

require_once '../../core/employee_auth.php';
EmployeeAuth::check('manage_providers');

$data = Request::get();

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

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

$query = "

SELECT
p.*,
pp.business_name,
pp.description,
pp.address,
pp.city_id,
pp.pincode,
pp.profile_photo,
pp.slug

FROM providers p

LEFT JOIN provider_profiles pp
ON p.id=pp.provider_id

WHERE p.id=:id

LIMIT 1

";

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

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

Response::success($stmt->fetch());