<?php
session_start();
require_once "../../../config.php";
require_once "../../../validation.php";
require_once "../../../Helper.php";
require_once '../../database1.php';

require_once "../../check_admin.php";

if(!isset($_GET['id']) || !is_numeric($_GET['id']))
{
    http_response_code(400);
    echo json_encode(array('error_text' => 'No input found'));
    exit;
}

$id = $_GET['id'];

class getCurrentChat extends database
{
   	public function getChats($id)
    {
        return $this->fetchAll('tb_chat', ['cl_chat_cutomer_id' => $id], 'cl_created_at', 'ASC');
    }

}


$obj = new getCurrentChat();   
$chats = $obj->getChats($id);


echo json_encode($chats);