```php
<?php

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

$data = Request::post();

try {

    Validator::required($data,[
        'plan_id',
        'name',
        'price',
        'validity_days'
    ]);

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

    $query = "

        UPDATE plans SET

        name = :name,
        price = :price,
        categories_allowed = :categories_allowed,
        daily_lead_limit = :daily_lead_limit,
        validity_days = :validity_days,
        description = :description

        WHERE id = :plan_id

    ";

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

    $stmt->execute([

        ':name'=>$data['name'],
        ':price'=>$data['price'],
        ':categories_allowed'=>$data['categories_allowed'] ?? null,
        ':daily_lead_limit'=>$data['daily_lead_limit'] ?? 0,
        ':validity_days'=>$data['validity_days'],
        ':description'=>$data['description'] ?? null,
        ':plan_id'=>$data['plan_id']

    ]);

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

}
catch(Exception $e){

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

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

}