本文整理汇总了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);
}
示例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]);
}
}
示例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);
}
示例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);
}
示例5: delete
public function delete($id)
{
Product::destroy($id);
return redirect('product');
}
示例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.');
}
示例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();
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Product::destroy($id);
}
示例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'));
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
return \App\Product::destroy($id);
}
示例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');
}
示例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');
}
示例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');
}
示例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);
}
示例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([]);
}
}