购物车优化
parent
385cf0d936
commit
4c863302fa
|
|
@ -56,6 +56,8 @@ class ShoppingCartItemController extends Controller
|
||||||
'quantity' => $input['quantity'],
|
'quantity' => $input['quantity'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$shoppingCartItem->setRelation('sku', $sku);
|
||||||
|
|
||||||
if (! $shoppingCartItem->wasRecentlyCreated) {
|
if (! $shoppingCartItem->wasRecentlyCreated) {
|
||||||
if ($shoppingCartItem->quantity + $input['quantity'] > $sku->saleable_stock) {
|
if ($shoppingCartItem->quantity + $input['quantity'] > $sku->saleable_stock) {
|
||||||
throw new ProductNotEnoughException();
|
throw new ProductNotEnoughException();
|
||||||
|
|
@ -64,7 +66,7 @@ class ShoppingCartItemController extends Controller
|
||||||
$shoppingCartItem->increment('quantity', $input['quantity']);
|
$shoppingCartItem->increment('quantity', $input['quantity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->noContent();
|
return ShoppingCartItemResource::make($shoppingCartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,7 +100,7 @@ class ShoppingCartItemController extends Controller
|
||||||
'specs' => $sku->specs,
|
'specs' => $sku->specs,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
return response()->noContent();
|
return ShoppingCartItemResource::make($shoppingCartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue