app/Http/Controllers/CartController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Cart  $cart
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function cartUpdate(Request $request)
    {
        $request->validate([
            'quantity' => ['required'],
            'quantity.*' => ['required'],
        ]);
        foreach($request->cart_id as $key => $cartId){
            $cart = Cart::findOrFail($cartId);
            $cart->quantity = $request->quantity[$key];
            $cart->save();
        }
        return redirect('cart/#cartupdate')->with('success', 'Cart Updated Successfully');
    }
public function cartUpdate ( Request $ request ) { $ request -> validate ( [ 'quantity' => [ 'required' ] , 'quantity.*' => [ 'required' ] , ] ) ; foreach ( $ request -> cart_id as $ key => $ cartId ) { $ cart = Cart :: findOrFail ( $ cartId ) ; $ cart -> quantity = $ request -> quantity [ $ key ] ; $ cart -> save ( ) ; } return redirect ( 'cart/#cartupdate' ) -> with ( 'success' , 'Cart Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .