```php
<?php

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


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

$data = Request::post();

try {

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

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

$title = Helper::sanitize($data['title']);

$slug = Slug::generateUnique(
'blog_posts',
'slug',
$title,
$data['id']
);

$featured_image = null;

if(isset($_FILES['featured_image'])){
$featured_image = Upload::image('featured_image','blog');
}

$query="

UPDATE blog_posts

SET
category_id=:category_id,
title=:title,
slug=:slug,
content=:content,
featured_image_alt=:featured_image_alt,
meta_title=:meta_title,
meta_description=:meta_description,
schema_markup=:schema_markup,
status=:status,
published_at=:published_at
";

if($featured_image){
$query.=",featured_image=:featured_image";
}

$query.=" WHERE id=:id";

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

$params=[

':id'=>$data['id'],
':category_id'=>$data['category_id'] ?? null,
':title'=>$title,
':slug'=>$slug,
':content'=>$data['content'] ?? null,
':featured_image_alt'=>$data['featured_image_alt'] ?? null,
':meta_title'=>$data['meta_title'] ?? null,
':meta_description'=>$data['meta_description'] ?? null,
':schema_markup'=>$data['schema_markup'] ?? null,
':status'=>$data['status'] ?? 'draft',
':published_at'=>$data['published_at'] ?? null

];

if($featured_image){
$params[':featured_image']=$featured_image;
}

$stmt->execute($params);

Logger::activity(
ApiAuth::employeeId(),
"update",
"blog_posts",
$data['id'],
ApiAuth::ip()
);

Response::success([],"Blog post updated");

}
catch(Exception $e){

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

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

}