35289-vm/public_html/catalog.php
Flatlogic Bot 163c483584 atual
2025-10-28 01:29:21 +00:00

62 lines
2.4 KiB
PHP

<?php
require_once __DIR__ . '/../app/Controllers/ProductController.php';
$productController = new ProductController();
$search_term = $_GET['q'] ?? null;
$page_title = 'Catálogo de Produtos';
$page_subtitle = 'Explore nossa coleção completa de cestas e presentes.';
if ($search_term) {
$products = $productController->search($search_term);
$page_title = 'Resultados da Busca';
$page_subtitle = 'Exibindo resultados para "' . htmlspecialchars($search_term) . '"';
} else {
$products = $productController->index();
}
require_once __DIR__ . '/../app/Views/public/header.php';
?>
<!-- Main Content -->
<main class="container my-5">
<div class="page-header">
<h1 class="display-4"><?= $page_title ?></h1>
<p class="lead text-muted"><?= $page_subtitle ?></p>
</div>
<!-- Products Grid -->
<section class="row mt-5">
<?php if (!empty($products)): ?>
<?php foreach ($products as $product): ?>
<?php
$image_path = !empty($product['image'])
? 'uploads/products/' . htmlspecialchars($product['image'])
: 'https://picsum.photos/600/400?random=' . $product['id'];
?>
<div class="col-lg-4 col-md-6 mb-4">
<div class="product-card">
<a href="product.php?slug=<?= htmlspecialchars($product['slug']) ?>" class="product-card-link">
<img src="<?= $image_path ?>" class="card-img-top" alt="<?= htmlspecialchars($product['name']) ?>">
<div class="card-body p-4">
<h5 class="card-title"><?= htmlspecialchars($product['name']) ?></h5>
<p class="card-price mb-3">R$ <?= number_format($product['price'], 2, ',', '.') ?></p>
<div class="d-grid">
<span class="btn btn-primary">Ver Detalhes</span>
</div>
</div>
</a>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="col-12">
<p class="text-center text-muted">Nenhum produto encontrado para sua busca.</p>
</div>
<?php endif; ?>
</section>
</main>
<?php
require_once __DIR__ . '/../app/Views/public/footer.php';
?>