```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();

try {

    Validator::required($data,[
        '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(
            'categories',
            'slug',
            $name
        );

    }


    $updateData = [

        "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,
        "canonical_url" => $data['canonical_url'] ?? null,
        "robots_index" => $data['robots_index'] ?? 'index',
        "schema_markup" => $data['schema_markup'] ?? null,
        "status" => $data['status'] ?? 1

    ];


    // Upload new images if provided
    $icon = Upload::image('icon','categories');

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


    $image = Upload::image('image','categories');

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


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


    $employee_id = ApiAuth::employeeId();

    Logger::activity(
        $employee_id,
        "update",
        "categories",
        $id,
        ApiAuth::ip()
    );


    Logger::log(
        "api.log",
        "Category updated: ".$name
    );


    Response::success([],"Category updated successfully");


}
catch(Exception $e){

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

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

}
