當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。