/**
  * @api {delete} /Products/{id} 删除指定的 product
  * @apiGroup Products
  * @apiVersion 0.0.1
  * @apiParam {Number}  id Product çš„ ID
  * @apiSuccessExample {json} Success-Response:
  *     HTTP/1.1 200 OK
  * @apiErrorExample {json} Error-Response:
  *     HTTP/1/1 404 Not Found
  */
 public function destroy($id)
 {
     //
     if (Product::destroy($id)) {
         return response('OK', 200);
     }
     return response('Not Found', 404);
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     if ($request->ajax()) {
         Product::destroy($id);
         $message = 'El producto fue eliminado satisfactoriamente';
         return response()->json(['message' => $message]);
     }
 }
 public function destroy($id)
 {
     // Submit a Request to Delete a Product
     try {
         Product::destroy($id);
     } catch (\Exception $e) {
         $messages = ['failed' => 'Product Deletion Failed!'];
         return response()->json(['success' => false, 'messages' => $messages], 400);
     }
     $messages = ['success' => 'Product Deleted!'];
     return response()->json(['success' => true, 'messages' => $messages], 200);
 }
Example #4
0
 public function postIndex(Request $request, $pid, $mode)
 {
     if ($mode == 'Delete') {
         // use DB facade to delete the row matching $pid
         \App\Product::destroy($pid);
         $request->session()->flash('message', 'Product ID ' . $request->input('productID') . ' Deleted');
     } else {
         // validate that the product ID is at least 5 characters
         $this->validate($request, ['productID' => 'required|min:5', 'productName' => 'required|min:5', 'category' => 'required', 'price' => 'required|numeric|min:3|max:100000', 'discount' => 'required|numeric|min:0|max:30', 'active' => 'required']);
         // create a model and set the values, then session_save_path
         if ($mode == 'Edit') {
             // get the model from the db
             $products = \App\Product::where('id', '=', $pid)->get();
             $product = $products->first();
         } else {
             // instantiate a new model
             $product = new \App\Product();
         }
         // now set the model attributes
         $product->product_id = $request->input('productID');
         $product->product_name = $request->input('productName');
         $product->category_id = $request->input('category');
         $product->price = $request->input('price');
         $product->max_discount = $request->input('discount');
         $product->active = $request->input('active');
         if ($mode == 'Edit') {
             $product->id = $pid;
         }
         $product->save();
         $request->session()->flash('message', 'Product ID ' . $product->product_id . ' Updated / Added');
     }
     $pcol = $request->session()->get('pcol');
     $pord = $request->session()->get('pord');
     $pord = $pord == 'A' ? 'D' : 'A';
     $request->session()->put('pord', $pord);
     // need to refresh the products collection after changes
     $products = \App\Product::orderBy('product_name')->get();
     // now put the collection in the session variable
     $request->session()->put('products', $products);
     // now direct to the sort route to retain the sort the user had before editing
     return redirect('products/sort/' . $pcol);
 }
Example #5
0
 public function delete($id)
 {
     Product::destroy($id);
     return redirect('product');
 }
 public function destroy($id)
 {
     $product = Product::find($id);
     if (!Product::destroy($id)) {
         return redirect()->back();
     }
     return redirect('products')->with('successMsg', $product->name . ' has been successfully deleted.');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = Product::find($id);
     $picture = $product->picture;
     if (!is_null($picture)) {
         Storage::delete($picture->uri);
         $picture->delete();
     }
     $product->delete();
     Product::destroy($id);
     //supprime en cascade les Tags associés aux produits
     //        Picture::find('')
     Session::flash('message', 'Product deleted');
     return back();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
 }
Example #9
0
 public function destroy(Request $request, $id)
 {
     empty($id) && !empty($request->input('id')) && ($id = $request->input('id'));
     $id = (array) $id;
     foreach ($id as $v) {
         $product = Product::destroy($v);
     }
     return $this->success('', count($id) > 5, compact('id'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     return \App\Product::destroy($id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     Product::destroy($id);
     return redirect('/admin/products');
 }
Example #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return redirect('admin/product')->with('message', 'delete success');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = Product::findOrFail($id);
     Product::destroy($id);
     return redirect(route('products.' . $product->section))->with('message', 'Producto ' . $product->name . ' eliminado corectamente');
 }
Example #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return response()->json(['success' => "product deleted"], 200);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $response = redirect('/wd/admin/products');
     //
     if (Product::destroy($id)) {
         return $response;
     } else {
         return $response->withErrors([]);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return Response::json(array('error' => false), 200);
 }
Example #17
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     Product::destroy($id);
     return redirect()->route('admin.product.index');
 }
 public function destroy($id)
 {
     $product = Product::find($id);
     $product->categories()->detach();
     foreach ($product->equivalences()->get() as $equivalence) {
         $equivalence->delete();
     }
     Product::destroy($id);
     return redirect('product/index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     Session::flash('flash_message', 'Product deleted!');
     return redirect('web/products');
 }
Example #20
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     Product::reindex();
     return;
 }
Example #21
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Request  $request
  * @return \Illuminate\Http\Response
  */
 public function multiple_delete(Request $request)
 {
     Product::destroy($request->ids);
     $response = ['model_type' => 'Product', 'ids' => $request->ids, 'action_type' => 'delete'];
     return json_encode($response);
 }
 public function destroy($id)
 {
     $response = \App\Product::destroy($id);
     return response()->json($response);
 }
Example #23
0
 public function destroy($id)
 {
     if ($id) {
         Product::destroy($id);
         Session::flash('flash_message', 'Product has been deleted successfully.');
         Session::flash('flash_type', 'alert-success');
     }
     return redirect('admin/products');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return back()->with('Product deleted');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param Request $request
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, int $id)
 {
     Product::destroy($id);
     return back()->with('success', 'Delete successful');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // working
     $result = Product::destroy($id);
     return response()->json(['result' => $result]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     Product::destroy($id);
     return redirect($request->input('redirect_to'));
 }
 public function deleteProduct($id)
 {
     $user = Auth::user();
     if ($user != null && $user->hasRole('admin')) {
         $result = Product::destroy($id);
         return redirect('admin/products');
     } else {
         return view('admin.login');
     }
 }
Example #29
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return redirect()->back();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return 'success';
 }