public function delete($id)
 {
     if (!Auth::user()->is_admin) {
         return Redirect::to('/');
     }
     Product::destroy($id);
     return Redirect::to('/admin');
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $del = Product::destroy($id);
     if ($del) {
         return "successfully deleted";
     } else {
         return 'not found';
     }
 }
Example #3
0
 public static function boot()
 {
     parent::boot();
     //This event will delete all related model in product model
     static::deleted(function ($productcat) {
         $r = $productcat->products()->lists('id');
         if (!empty($r)) {
             Product::destroy($r);
         }
     });
     //Validation on create
     static::creating(function ($productcat) {
         return $productcat->isValid();
     });
 }
Example #4
0
 public function destroy()
 {
     if (!isset($_POST['product_id']) || !isset($_POST['pwd'])) {
         return call('pages', 'error');
     }
     require_once 'models/user.php';
     if (!User::find($_SESSION['username'], $_POST['pwd'])) {
         $_SESSION['alert'] = "Wrong password!";
         return header("Location: index.php?controller=products&action=index");
     }
     $id = intval($_POST['product_id']);
     Product::destroy($_POST['product_id']);
     $_SESSION['notice'] = "Deleted product successfully!";
     header("Location: index.php?controller=products&action=index");
 }
Example #5
0
 /**
  * Remove the specified product from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return Redirect::route('products.index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return Response::json(array('success' => true));
 }
 public function deleteProducts()
 {
     $ids = explode(',', Input::get('javascriptArrayString'));
     //Log
     $products = [];
     foreach ($ids as $id) {
         $products[] = Product::where('id', $id)->pluck('name');
     }
     $dbID = $ids[0];
     $productModel = Product::find($dbID);
     $brandName = $productModel->brand()->pluck('name');
     $catName = $productModel->categories()->pluck('name');
     if (!empty($products)) {
         $log['products'] = "[ {$brandName} / {$catName} ]";
         $log['stock_items'] = implode(' | ', $products);
         $log['stocktype'] = 'delete';
         $this->_saveActivityLog($log);
     }
     Product::destroy($ids);
     $data['status'] = 'success';
     $data['message'] = 'Deleted successfully';
     return Response::json($data);
 }
 public function destroyProduct($product_id)
 {
     Product::destroy($product_id);
 }
 public function multiDestroy()
 {
     $items = json_decode(Input::get("items"));
     foreach ($items as $item) {
         Product::destroy($item);
     }
     return Response::json(array('success' => true, 'items' => $items, 'message' => array('type' => 'success', 'msg' => 'Xóa hàng hóa thành công!')));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return Redirect::route('admin.products.index')->with('info', 'Het product is succesvol verwijderd.');
 }