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

require_once '../check_edit_page_ajax.php';

class delete_banner2_image_ajax extends database{
	public function index($id)
	{
		$where['cl_id'] = $id;
		$data['cl_deleted_at'] = date("Y-m-d H:i:s");
		return $this->update('tb_product_category_banners2', $data,$where);
	}

	public function getFile($id)
	{
		$where['cl_id'] = $id;
		return $this->fetchRow('tb_product_category_banners2', $where);
	}
}


$obj = new delete_banner2_image_ajax();
$file = $obj->getFile($id);
if(!$file)
{
	http_response_code(401);
	echo json_encode(array('error_text' => 'File Not Found'));
	exit;
}
$res = $obj->index($id);
if(!$res)
{
	http_response_code(401);
	echo json_encode(array('error_text' => 'Something Went Wrong'));
	exit;
}

unlink('../../../../posty/public/uploads/product_category/' . $file['cl_image']);



http_response_code(200);
echo json_encode(array('message' => 'File Deleted Successfully'));
exit;