public function delete($productId = null) { Functions::EditorAuthorization(); $productModel = new ProductsModel(); if ($productId) { try { $productModel->deleteProductById($productId); } catch (\Exception $e) { $model['errors'][] = $e->getMessage(); } } $products = $productModel->getAllProducts(); $model['products'] = $products; return new View($model); }