This repository was archived by the owner on Jul 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Products list #40
Merged
Merged
Products list #40
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| require __DIR__ .'/../models/Product.php'; | ||
|
|
||
| class ProductController { | ||
| private $productModel; | ||
|
|
||
| public function __construct(PDO $dbConnection) { | ||
| $this->productModel = new Product($dbConnection); | ||
| } | ||
|
|
||
| public function viewProducts() { | ||
| $title = "View Products"; | ||
| $products = $this->productModel->getAll(); | ||
| require_once __DIR__ . "/../views/products.php"; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,4 +11,4 @@ | |
| </div>"; | ||
| } | ||
| ?> | ||
| </div> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,23 @@ | ||
| <?php require_once '../controllers/products.php' ?> | ||
| <?php include 'partials/header.php'; ?> | ||
| <?php if (!isset($_SESSION['user'])): ?> | ||
| <div role="alert"> | ||
| You have to be signed-in to view this page. | ||
| </div> | ||
| <?php include 'partials/footer.php'; ?> | ||
| <?php exit; ?> | ||
| <?php endif; ?> | ||
|
|
||
| <div> | ||
| <h1>Product list</h1> | ||
| <!--FIXME: fix category table, to organise products by category (those seen on the menu)--> | ||
| <?php | ||
|
|
||
| foreach ($products as $product) { | ||
| echo "<div> | ||
| <p>" . $product->name . "</p> | ||
| <p>" . $product->price . "</p> | ||
| <p>" . $product->name . " - " . $product->price . "€</p> | ||
|
|
||
| <!-- | ||
| <form method='POST' action='index.php'> | ||
| <input type='hidden' name='product_id' value='" . $product->id . "'> | ||
| <button type='submit' name='action' value='add'>Add to Cart</button> | ||
| <button type='submit' name='action' value='remove'>Remove one</button> | ||
| </form> | ||
| --> | ||
| </div>"; | ||
| } | ||
| ?> | ||
| </div> | ||
| <?php include 'partials/footer.php'; ?> | ||
| <?php include 'partials/footer.php'; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.