当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::destroy方法代码示例

本文整理汇总了PHP中app\Product::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::destroy方法的具体用法?PHP Product::destroy怎么用?PHP Product::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Product的用法示例。


在下文中一共展示了Product::destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destroy

 /**
  * @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);
 }
开发者ID:genee-projects,项目名称:snail,代码行数:18,代码来源:ProductsController.php

示例2: destroy

 /**
  * 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]);
     }
 }
开发者ID:lamente22,项目名称:LaraAjax,代码行数:14,代码来源:ProductController.php

示例3: destroy

 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);
 }
开发者ID:xenxa,项目名称:essensanaturaleonline,代码行数:12,代码来源:ProductController.php

示例4: postIndex

 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);
 }
开发者ID:bsmitty54,项目名称:P4,代码行数:42,代码来源:ProducteditController.php

示例5: delete

 public function delete($id)
 {
     Product::destroy($id);
     return redirect('product');
 }
开发者ID:roncloud07,项目名称:medium,代码行数:5,代码来源:ProductController.php

示例6: destroy

 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.');
 }
开发者ID:yevta,项目名称:laravel-catalog,代码行数:8,代码来源:ProductController.php

示例7: destroy

 /**
  * 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();
 }
开发者ID:lionel-kahan,项目名称:Star-Wars,代码行数:21,代码来源:ProductController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
 }
开发者ID:roopunk,项目名称:fashionove,代码行数:10,代码来源:ProductsController.php

示例9: destroy

 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'));
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:9,代码来源:ProductController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     return \App\Product::destroy($id);
 }
开发者ID:BrunoDG,项目名称:laravelTest,代码行数:10,代码来源:ProductsController.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     Product::destroy($id);
     return redirect('/admin/products');
 }
开发者ID:habibimroncn,项目名称:tutorial-laravel,代码行数:12,代码来源:ProductController.php

示例12: destroy

 /**
  * 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');
 }
开发者ID:OrestHk,项目名称:e-starwars,代码行数:11,代码来源:ProductController.php

示例13: destroy

 /**
  * 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');
 }
开发者ID:edwardricardo,项目名称:zenska,代码行数:12,代码来源:ProductController.php

示例14: destroy

 /**
  * 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);
 }
开发者ID:c134,项目名称:ShopREST,代码行数:11,代码来源:ProductsController.php

示例15: destroy

 /**
  * 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([]);
     }
 }
开发者ID:supermason,项目名称:homestreward,代码行数:16,代码来源:ProductsController.php


注:本文中的app\Product::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。