corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-23 47a5842b7eae4aa4fea971846957cd8889f41efd
creazione pagina per modificare un determinato product (parte 133)
1 files added
2 files modified
21 ■■■■■ changed files
src/App/Controllers/products.php 13 ●●●●● patch | view | raw | blame | history
views/Products/edit.php 6 ●●●●● patch | view | raw | blame | history
views/Products/show.php 2 ●●●●● patch | view | raw | blame | history
src/App/Controllers/products.php
@@ -26,6 +26,19 @@
        ]);
    }
    public function edit(string $id) {
        $product = $this->model->find($id);
        if( $product == false ) {
            throw new PageNotFoundException("Product not found");
        }
        echo $this->viewer->render("shared/header.php", [
            "title"=> "Edit product"
        ]);
        echo $this->viewer->render("Products/edit.php", [
            "product"=> $product
        ]);
    }
    public function showPage(string $title, string $id, string $page) {
        echo $title, " ", $id, " ", $page;
    }
views/Products/edit.php
New file
@@ -0,0 +1,6 @@
<body>
    <h1>Edit Product</h1>
    <p><a href="/products/<?= $product["id"] ?>/show" >Cancel</a></p>
</body>
</html>
views/Products/show.php
@@ -1,6 +1,8 @@
<body>
    <h1><?= $product["name"] ?></h1>
    <p><?= $product["description"] ?></p>
    <p><a href="/products/<?= $product["id"] ?>/edit" >Edit</a></p>
</body>
</html>