From 7739eae8d2d52578839eb771d7200a75dd582396 Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Tue, 14 May 2024 11:56:28 +0200 Subject: [PATCH] rimuovendo le credenziali del database e inizializzazione costruttore (parte 87) --- src/App/Controllers/products.php | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index d7a0bde..d7d2159 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -3,19 +3,22 @@ use App\Models\Product; use Framework\Viewer; class Products { + public function __construct(private Viewer $viewer, private Product $model) { } public function index() { + + $products = $this->model->getData(); - $model = new Product; - $products = $model->getData(); - - $viewer = new Viewer; - - require "views/products_index.php"; + echo $this->viewer->render("shared/header.php"); + echo $this->viewer->render("Products/index.php", [ + "products"=> $products + ]); } public function show(string $id) { - var_dump($id); - require "views/products_show.php"; + echo $this->viewer->render("shared/header.php"); + echo $this->viewer->render("Products/show.php", [ + "id"=> $id + ]); } public function showPage(string $title, string $id, string $page) { -- Gitblit v1.8.0