From 766451d7a969ca8b6b80d7da206ef76e3f376925 Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Tue, 21 May 2024 10:15:31 +0200
Subject: [PATCH] creazione di una base Model da applicare a tutti i modelli (parte 120)

---
 src/App/Controllers/products.php |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php
index a6e41d6..684e90c 100644
--- a/src/App/Controllers/products.php
+++ b/src/App/Controllers/products.php
@@ -1,12 +1,13 @@
 <?php
 namespace App\Controllers;
 use App\Models\Product;
+use Framework\Exceptions\PageNotFoundException;
 use Framework\Viewer;
 class Products {
     public function __construct(private Viewer $viewer, private Product $model) { }
     public function index() {
         
-        $products = $this->model->getData();
+        $products = $this->model->findAll();
 
         echo $this->viewer->render("shared/header.php");
         echo $this->viewer->render("Products/index.php", [
@@ -16,6 +17,9 @@
 
     public function show(string $id) {
         $product = $this->model->find($id);
+        if( $product == false ) {
+            throw new PageNotFoundException("Product not found");
+        }
         echo $this->viewer->render("shared/header.php");
         echo $this->viewer->render("Products/show.php", [
             "product"=> $product

--
Gitblit v1.8.0