public function delete($id)
 {
     if (!$this->isLogged()) {
         Header('Location: ' . $this->directories . '/users/login');
     }
     if ($_SESSION['role'] != 'admin') {
         if ($_SESSION['role'] != 'editor') {
             Header('Location: ' . $this->directories . '/home/index');
         }
     }
     $model = new Product();
     $model->delete($id);
     Header('Location: ' . $this->directories . '/products/showAll');
 }
예제 #2
0
 public function products()
 {
     $model = new Product();
     $products = [];
     if (count($_SESSION['cart']) > 0) {
         if (isset($_SESSION['cart'])) {
             foreach ($_SESSION['cart'] as $productId) {
                 $product = $model->getProductById($productId);
                 array_push($products, $product);
             }
         }
     }
     return new View($products);
 }