This repository was archived by the owner on Jul 20, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require __DIR__ .'/../models/Product.php ' ;
4+
5+ class ProductController {
6+ private $ productModel ;
7+
8+ public function __construct (PDO $ dbConnection ) {
9+ $ this ->productModel = new Product ($ dbConnection );
10+ }
11+
12+ public function viewProducts () {
13+ $ title = "View Products " ;
14+ $ products = $ this ->productModel ->getAll ();
15+ require_once __DIR__ . "/../views/products.php " ;
16+ }
17+ }
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1111 </div> " ;
1212 }
1313 ?>
14- </div>
14+ </div>
Original file line number Diff line number Diff line change 1111 <li><a href="/">Home</a></li>
1212 <?php if ($ userId ) { ?>
1313 <li><a href="#">Order</a></li>
14+ <li><a href="/products">Products list</a></li>
1415 <li><a href="/account">My account</a></li>
1516 <li><a href="/basket">Cart</a></li>
1617 <li><a href="/sign-out">Sign out</a></li>
2021 <?php } ?>
2122 </ul>
2223 </div>
23- </nav>
24+ </nav>
Original file line number Diff line number Diff line change 1- <?php require_once '../controllers/products.php ' ?>
21<?php include 'partials/header.php ' ; ?>
3- <?php if (!isset ($ _SESSION ['user ' ])): ?>
4- <div role="alert">
5- You have to be signed-in to view this page.
6- </div>
7- <?php include 'partials/footer.php ' ; ?>
8- <?php exit ; ?>
9- <?php endif ; ?>
102
113<div>
124 <h1>Product list</h1>
135 <!--FIXME: fix category table, to organise products by category (those seen on the menu)-->
146 <?php
7+
158 foreach ($ products as $ product ) {
169 echo "<div>
17- <p> " . $ product ->name . "</p>
18- <p> " . $ product ->price . "</p>
10+ <p> " . $ product ->name . " - " . $ product ->price . "€</p>
11+
12+ <!--
1913 <form method='POST' action='index.php'>
2014 <input type='hidden' name='product_id' value=' " . $ product ->id . "'>
2115 <button type='submit' name='action' value='add'>Add to Cart</button>
2216 <button type='submit' name='action' value='remove'>Remove one</button>
2317 </form>
18+ -->
2419 </div> " ;
2520 }
2621 ?>
2722</div>
28- <?php include 'partials/footer.php ' ; ?>
23+ <?php include 'partials/footer.php ' ; ?>
You can’t perform that action at this time.
0 commit comments