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

require_once '../../database1.php';
require_once "../../check_admin.php";

class addAjax extends database
{
   public function index($name)
    {
    	 $sql = " SELECT * FROM tb_product WHERE cl_name LIKE  '" . $name . "%' AND cl_deleted_at IS NULL ";
        return $this->callQuery($sql);
    }

    public function checkSlug($slug)
    {
    	$where['cl_slug'] = $slug;
    	return $this->fetchRow('tb_product', $where);
    }
}


$obj = new addAjax();
if(!isset($_POST['name']))
{
	http_response_code(400);
	echo json_encode(array('No input found'));
	exit;
}

$name = $_POST['name'];


$products = $obj->index($name);


http_response_code(200);
echo json_encode($products);
exit;