From 75438d3b6c46f9566ff7f6a9657dda7cdfbf9a6d Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Wed, 15 May 2024 09:36:01 +0200 Subject: [PATCH] questo permette alla classe database di crearsi solamente nelle pagine in cui รจ richiesta (parte 90) --- src/App/Controllers/products.php | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index 4e76a58..d7d2159 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -3,20 +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; - echo $viewer->render("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