middleware(CheckProductIsInStock::class)->only(['store', 'update']); } /** * Store a newly created resource in storage. * * @param \Modules\Cart\Http\Requests\StoreCartItemRequest $request * @return \Illuminate\Http\Response */ public function store(StoreCartItemRequest $request) { Cart::store($request->product_id, $request->qty, $request->options ?? []); return Cart::instance(); } /** * Update the specified resource in storage. * * @param mixed $cartItemId * @return \Illuminate\Http\Response */ public function update($cartItemId) { Cart::updateQuantity($cartItemId, request('qty')); try { resolve(Pipeline::class) ->send(Cart::coupon()) ->through($this->checkers) ->thenReturn(); } catch (MinimumSpendException | MaximumSpendException $e) { Cart::removeCoupon(); } return Cart::instance(); } /** * Remove the specified resource from storage. * * @param string $cartItemId * @return \Illuminhtate\Http\Response */ public function destroy($cartItemId) { Cart::remove($cartItemId); return Cart::instance(); } }