<?php
$mysqli = new mysqli("localhost", "root", "", "constra_db");
if ($mysqli->connect_error) die("Connection failed: " . $mysqli->connect_error);

$base_dir = "C:\\Users\\ADMIN\\.gemini\\antigravity\\brain\\719218d4-cb54-4610-8cdd-8d986ce5eea0\\";
$target_dir = "c:\\xampp\\htdocs\\constra\\public\\uploads\\categories\\";

$images = [
    'government_projects.png' => 'cat_government_projects_1777865997814.png',
    'interior_design.png' => 'cat_interior_design_1777866019582.png',
    'general_construction.png' => 'cat_general_construction_1777866038070.png'
];

foreach ($images as $new_name => $old_name) {
    if (copy($base_dir . $old_name, $target_dir . $new_name)) {
        $url = "http://localhost/constra/public/uploads/categories/" . $new_name;
        // Update DB by name
        $name = "";
        if ($new_name == 'government_projects.png') $name = "Government Projects";
        if ($new_name == 'interior_design.png') $name = "Interior Design";
        if ($new_name == 'general_construction.png') $name = "General Construction";
        
        $mysqli->query("UPDATE categories SET image = '$url' WHERE name = '$name'");
        echo "Updated $name\n";
    }
}

echo "All images updated with correct paths";
$mysqli->close();
?>
