public static function completeDeleteProduct()
 {
     require_once 'Product.model.php';
     $data = array();
     if (isset($_POST['deleteProduct'])) {
         $id = $_POST['product_id'];
         try {
             $result = ProductModel::deleteProduct($id);
             $data['products'] = ProductModel::getMyProducts();
             $data['redirect'] = '?/Product/myProducts';
         } catch (Exception $e) {
             $data['error'] = $e->getMessage();
             $data['template'] = 'error.html';
         }
     } else {
         $data['redirect'] = '?/User/home';
     }
     return $data;
 }
예제 #2
0
 /**
  * Delete product
  *
  *@return redirect
  */
 function postDeleteProduct()
 {
     $vendorID = Input::get('vendor_id');
     $productID = Input::get('product_id');
     $path = base_path() . '/uploads/products/' . $vendorID . '/' . $productID;
     if (is_dir($path)) {
         $files = glob($path . '/*');
         foreach ($files as $file) {
             if (is_file($file)) {
                 unlink($file);
             }
         }
         $deleteDir = rmdir($path);
     }
     ProductModel::deleteProduct($productID);
 }
예제 #3
0
 /**
  * Delete product
  *
  *@return redirect
  */
 function getDeleteProduct($vendorID, $productID)
 {
     $path = base_path() . '/uploads/products/' . $vendorID . '/' . $productID;
     if (is_dir($path)) {
         $files = glob($path . '/*');
         foreach ($files as $file) {
             if (is_file($file)) {
                 unlink($file);
             }
         }
         $deleteDir = rmdir($path);
     }
     ProductModel::deleteProduct($productID);
     return Redirect::to('/admin');
 }