本文整理匯總了PHP中app\Order::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::delete方法的具體用法?PHP Order::delete怎麽用?PHP Order::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Order
的用法示例。
在下文中一共展示了Order::delete方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: destroy
/**
* Destroy the given order.
*
* @param Request $request
* @param Order $order
* @return Response
*/
public function destroy(Request $request, Order $order)
{
if (\Auth::id() == $order->user_id) {
$order->delete();
}
return redirect('/orders');
}
示例2: complete
/**
* Complete the order
*
* @param Product $product
* @param Order $order
* @return \Illuminate\Http\Response
*/
public function complete(Product $product, Order $order)
{
$dateOrdered = Carbon::parse($order->created_at);
$lead_time = $dateOrdered->diffInDays(Carbon::now());
$product = DB::transaction(function () use($product, $order, $lead_time) {
$product->stocks()->create(['amount' => $order->amount, 'in_stock' => $order->amount, 'cost' => $order->cost, 'lead_time' => $lead_time]);
$product->updateStock();
return $product;
});
$order->delete();
return redirect()->route('product.show', $product);
}
示例3: getDelete
/**
* Удаляет заказ
*/
public function getDelete(Order $order)
{
$order->delete();
return redirect()->back()->with('success', 'Заказ успешно удалён.');
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param Order $order
* @return \Illuminate\Http\Response
*/
public function destroy(Order $order)
{
$order->delete();
return $this->jsonRespond->respondDelete();
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Order $order)
{
$baskets = $order->user->baskets->where('order_id', $order->id);
if ($order !== null) {
if ($order->delete()) {
foreach ($baskets as $basket) {
$basket->delete();
}
return back()->with('با موفقیت ثبت شد.');
}
} else {
return back()->withErrors('خطا در اتصال به پایگاه داده.');
}
}