<?php

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

$data = Request::get();

try {

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

    $query = "

        SELECT

        id,
        name,
        price,
        categories_allowed,
        daily_lead_limit,
        validity_days,
        description,
        status,
        created_at

        FROM plans

        ORDER BY price ASC

    ";

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

    $stmt->execute();

    $plans = $stmt->fetchAll();

    Response::success($plans);

}
catch(Exception $e){

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

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

}