From 7bc6e3058c600c716c0d427208b201eecdbd70ca Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Mon, 06 May 2024 11:11:16 +0200
Subject: [PATCH] gestione views utilizzando variabile globale _GET[] (parte 16)

---
 index.php                    |   10 +++++++++-
 /dev/null                    |    5 -----
 src/controllers/products.php |    4 ++--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/index.php b/index.php
index 5fb466a..98326de 100644
--- a/index.php
+++ b/index.php
@@ -2,4 +2,12 @@
 
 require "src/controllers/products.php";
 $controller = new Products;
-$controller->index();
\ No newline at end of file
+$action = $_GET["action"];
+
+
+if($action === "index") {
+    $controller->index();
+}elseif($action === "show") {
+    $controller->show();
+}
+    
\ No newline at end of file
diff --git a/show.php b/show.php
deleted file mode 100644
index 4690b60..0000000
--- a/show.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-require "src/controllers/products.php";
-$controller = new Products;
-$controller->show();
\ No newline at end of file
diff --git a/src/controllers/products.php b/src/controllers/products.php
index 331ccfc..366049b 100644
--- a/src/controllers/products.php
+++ b/src/controllers/products.php
@@ -2,9 +2,9 @@
 
 class Products {
     public function index() {
-        require "model.php";
+        require "src/models/product.php";
     
-        $model = new Model;
+        $model = new Product;
         $products = $model->getData();
 
         require "views/products_index.php";

--
Gitblit v1.8.0