<?php

require_once '../config/database.php';

$db = getDB();

$sql = "
SELECT *
FROM categories
WHERE is_active = 1
ORDER BY id DESC
";

$result = $db->query($sql);

$data = [];

while($row = $result->fetch_assoc()){

    $data[] = [

        "id" => $row['id'],

        "name_en" => $row['name_en'],

        "name_bn" => $row['name_bn'],

        "image" =>
            BASE_URL .
            "uploads/categories/" .
            $row['image'],
    ];
}

echo json_encode([
    "success" => true,
    "categories" => $data
]);