PK,ZbCartController.phpnu[cartModel = $cartModel ?? new CartModel(); } public function addToCart($userId, $data): void { if (!isset($data['product_id'], $data['quantity'])) { JsonResponse::send(['error' => 'Missing required fields'], 400); return; } $success = $this->cartModel->add($userId, $data['product_id'], $data['quantity']); if ($success) { JsonResponse::send(['success' => 'Product added to cart']); } else { JsonResponse::send(['error' => 'Failed to add to cart'], 500); } } public function removeFromCart($userId, $itemId): void { $success = $this->cartModel->remove($userId, $itemId); if ($success) { JsonResponse::send(['success' => 'Item removed from cart']); } else { JsonResponse::send(['error' => 'Failed to remove item'], 500); } } public function getCart($userId): void { $items = $this->cartModel->getItems($userId); JsonResponse::send(['cart' => $items]); } public function clearCart($userId): void { $this->cartModel->clear($userId); JsonResponse::send(['success' => 'Cart cleared']); } } PK,Z HeroImageController.phpnu[model = new HeroModel($database->getConnection()); } public function uploadHeroImage(array $files): void { if (!isset($files['hero_image'])) { $this->jsonResponse(false, 'No image uploaded.'); return; } $image = $files['hero_image']; $imageName = time() . '_' . basename($image['name']); $targetPath = $this->uploadDir . $imageName; if (!move_uploaded_file($image['tmp_name'], $targetPath)) { $this->jsonResponse(false, 'Image upload failed.'); return; } if ($this->model->insertHeroImage($imageName)) { $this->jsonResponse(true, 'Hero image uploaded successfully.'); } else { $this->jsonResponse(false, 'Database error.'); } } public function deleteHeroImage(array $data): void { $id = $data['delete_hero_id'] ?? null; $image = $data['delete_hero_image'] ?? null; if (!$id || !$image) { $this->jsonResponse(false, 'Missing data for deletion.'); return; } $filePath = $this->uploadDir . $image; if (file_exists($filePath)) { unlink($filePath); } if ($this->model->deleteHeroImage((int)$id)) { $this->jsonResponse(true, 'Hero image deleted successfully.'); } else { $this->jsonResponse(false, 'Database error.'); } } private function jsonResponse(bool $success, string $message): void { echo json_encode([ 'status' => $success ? 'success' : 'error', 'message' => $message ]); } } PK,Zs88LocationController.phpnu[model = new LocationModel($database->getConnection()); } public function insertLocation(array $post): void { if (empty($post['country']) || empty($post['town']) || !is_numeric($post['delivery_price'])) { $this->jsonResponse(false, 'All fields are required and must be valid.'); return; } if ($this->model->insert($post)) { $this->jsonResponse(true, 'Location added successfully.'); } else { $this->jsonResponse(false, 'Failed to add location.'); } } public function updateLocation(array $post): void { if (empty($post['id']) || empty($post['country']) || empty($post['town']) || !is_numeric($post['delivery_price'])) { $this->jsonResponse(false, 'Invalid data provided.'); return; } if ($this->model->update($post)) { $this->jsonResponse(true, 'Location updated successfully.'); } else { $this->jsonResponse(false, 'Update failed.'); } } public function deleteDeliveryLocation(int $id): void { if ($this->model->delete($id)) { $this->jsonResponse(true, 'Location deleted.'); } else { $this->jsonResponse(false, 'Failed to delete location.'); } } public function deleteFooter(int $id): void { if ($this->model->deleteFooter($id)) { $this->jsonResponse(true, 'Footer location deleted.'); } else { $this->jsonResponse(false, 'Could not delete footer location.'); } } private function jsonResponse(bool $success, string $message): void { echo json_encode([ 'status' => $success ? 'success' : 'error', 'message' => $message ]); } } PK,ZTDlNotificationController.phpnu[notification = new Notification(); } public function delete($id) { if (!$id || !is_numeric($id)) { return Response::json(['status' => 'error', 'message' => 'Invalid notification ID']); } $result = $this->notification->deleteNotification($id); if ($result) { return Response::json(['status' => 'success', 'message' => 'Notification deleted']); } return Response::json(['status' => 'error', 'message' => 'Failed to delete']); } } PK,Z%OrderController.phpnu[changeStatus($orderId)) { Response::redirect('../pending_orders.php'); } } if (isset($_GET['cancel_Id'])) { $orderId = $_GET['cancel_Id']; if ((new Order())->cancel($orderId)) { Response::redirect('../pending_orders.php'); } } if (isset($_GET['co_id'])) { $orderId = $_GET['co_id']; if ((new Order())->deleteComplete($orderId)) { Response::redirect('../complete_orders.php'); } } if (isset($_GET['po_id'])) { $orderId = $_GET['po_id']; if ((new Order())->deletePending($orderId)) { Response::redirect('../pending_orders.php'); } } if (isset($_GET['cco_id'])) { $orderId = $_GET['cco_id']; if ((new Order())->deleteComplete($orderId)) { Response::redirect('../canceled_orders.php'); } } if (isset($_GET['order_Id'])) { $orderId = $_GET['order_Id']; if ((new Order())->deleteFromView($orderId)) { Response::redirect('../view_orders.php'); } } } public function placeOrder() { if ($_POST['Mode'] === 'order_place') { session_start(); $order = new Order(); $order->place( $_SESSION['uid'], $_POST['shipping_address'], $_POST['total_price'], $_POST['payment_method'], $_POST['delivery_location_id'], $_POST['order_note'] ); } } } PK,Z =SearchController.phpnu[search = new Search(); } public function search($data) { if (empty($data['search'])) { return Response::json(['status' => 'error', 'message' => 'Search query cannot be empty']); } $results = $this->search->performSearch($data['search']); if ($results) { return Response::json(['status' => 'success', 'results' => $results]); } return Response::json(['status' => 'error', 'message' => 'No results found']); } } PK,Zn^UserController.phpnu[model = new UserModel($database->getConnection()); } public function deleteUser(int $id): void { if (!$id || !is_numeric($id)) { $this->jsonResponse(false, 'Invalid user ID'); return; } if ($this->model->deleteUserById($id)) { $this->jsonResponse(true, 'User deleted successfully'); } else { $this->jsonResponse(false, 'Failed to delete user'); } } private function jsonResponse(bool $success, string $message): void { echo json_encode([ 'status' => $success ? 'success' : 'error', 'message' => $message ]); } } PK,ZbCartController.phpnu[PK,Z ,HeroImageController.phpnu[PK,Zs88QLocationController.phpnu[PK,ZTDlNotificationController.phpnu[PK,Z%OrderController.phpnu[PK,Z =@"SearchController.phpnu[PK,Zn^V%UserController.phpnu[PKR1)