<?php

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

$data = Request::get();

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

$crud = new CrudService($conn);

$options = [

    "page"   => $data['page'] ?? 1,
    "limit"  => $data['limit'] ?? 10,
    "search" => $data['search'] ?? null,
    "status" => $data['status'] ?? 1,
    "sort"   => $data['sort'] ?? 'id',
    "order"  => $data['order'] ?? 'DESC'

];

$categories = $crud->list("categories",$options);

Response::success($categories);
