corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-14 7baa142488879722eaffe263ddc064072f4df973
commit | author | age
026ec0 1 <?php
c042bc 2 namespace App\Controllers;
5cc38b 3 use App\Models\Product;
157da9 4 use Framework\Viewer;
c54720 5 class Products {
f76104 6     public function __construct(private Viewer $viewer, private Product $product) { }
026ec0 7     public function index() {
be68f1 8
5cc38b 9         $model = new Product;
026ec0 10         $products = $model->getData();
F 11
f76104 12         echo $this->viewer->render("shared/header.php");
F 13         echo $this->viewer->render("Products/index.php", [
6a2226 14             "products"=> $products
F 15         ]);
026ec0 16     }
2e7bc3 17
a93a2f 18     public function show(string $id) {
f76104 19         echo $this->viewer->render("shared/header.php");
F 20         echo $this->viewer->render("Products/show.php", [
8fdeaa 21             "id"=> $id
F 22         ]);
2e7bc3 23     }
1f822b 24
F 25     public function showPage(string $title, string $id, string $page) {
1e5093 26         echo $title, " ", $id, " ", $page;
1f822b 27     }
026ec0 28 }