```php
<?php

require_once '../../core/api_bootstrap.php';
require_once '../../core/employee_auth.php';
EmployeeAuth::check('view_analytics');
try {

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

$query="

SELECT

DATE(created_at) AS lead_date,
COUNT(id) AS total_leads

FROM customer_leads

GROUP BY lead_date

ORDER BY lead_date ASC

";

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

$data = $stmt->fetchAll();

Response::success($data);

}
catch(Exception $e){

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

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

}