corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-24 6a797275048f9d5e55d65a35ba4b6a21ec69d074
aggiunta di un metodo separato per la gestione delle eliminazioni dei record (da fixare) (parte 142)
2 files modified
11 ■■■■■ changed files
src/App/Controllers/products.php 9 ●●●●● patch | view | raw | blame | history
views/Products/delete.php 2 ●●● patch | view | raw | blame | history
src/App/Controllers/products.php
@@ -116,4 +116,13 @@
            "product" => $product
        ]);
    }
    public function destroy(string $id) {
        $product = $this->getProduct($id);
        $this->model->delete($id);
        header("Location: /products/index");
        exit;
    }
}
views/Products/delete.php
@@ -1,7 +1,7 @@
<body>
    <h1>Delete Product</h1>
    <form method="post" action="/products/<?= $product["id"]?>/delete">
    <form method="post" action="/products/<?= $product["id"]?>/destroy">
        <p>Delete this product?</p>
        <button>Yes</button>
    </form>