```php
<?php

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


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

$data = Request::post();

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

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

$crud = new CrudService($conn);

$id = (int)$data['id'];

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

$slug = $data['slug'] ?? '';

if(empty($slug)){
    $slug = Slug::generateUnique(
        'sub_categories',
        'slug',
        $name
    );
}

$updateData = [

    "category_id"=>$data['category_id'],
    "name"=>$name,
    "slug"=>$slug,
    "short_description"=>$data['short_description'],
    "description"=>$data['description'] ?? null,
    "seo_content"=>$data['seo_content'] ?? null,
    "meta_title"=>$data['meta_title'] ?? null,
    "meta_description"=>$data['meta_description'] ?? null,
    "meta_keywords"=>$data['meta_keywords'] ?? null,
    "schema_markup"=>$data['schema_markup'] ?? null,
    "status"=>$data['status'] ?? 1

];


$icon  = Upload::image('icon','subcategories');
$image = Upload::image('image','subcategories');

if($icon){
    $updateData['icon']=$icon;
}

if($image){
    $updateData['image']=$image;
}


$crud->update('sub_categories',$updateData,$id);


Logger::activity(
    ApiAuth::employeeId(),
    "update",
    "sub_categories",
    $id,
    ApiAuth::ip()
);


Response::success([],"Subcategory updated");