| | |
| | | <?php |
| | | namespace App\Controllers; |
| | | 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 \App\Models\Product; |
| | | $products = $model->getData(); |
| | | |
| | | require "views/products_index.php"; |
| | | echo $this->viewer->render("shared/header.php"); |
| | | echo $this->viewer->render("Products/index.php", [ |
| | | "products"=> $products |
| | | ]); |
| | | } |
| | | |
| | | public function show() { |
| | | require "views/products_show.php"; |
| | | public function show(string $id) { |
| | | 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) { |
| | | echo $title, " ", $id, " ", $page; |
| | | } |
| | | } |