diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index fcaeaf6..12b584c 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -163,6 +163,42 @@ class MainController extends Controller return redirect()->back()->with('success', 'Item deleted from cart successfully!'); } + // public function updateCartItem(Request $data, $id) + // { + // if (session()->has('id')) { + // $item = Cart::find($data->input('id')); + // $item->quantity = $data->input('quantity'); + // $item->save(); + // return redirect()->back()->with('success', 'Item updated successfully!'); + // } else { + // return redirect('/login')->with('error', 'Please login to update item!'); + // } + // } + + public function updateCartItem(Request $request, $id) + { + // dd($request->all()); + if (session()->has('id')) { + $item = Cart::find($id); + if ($item) { + $item->quantity = $request->input('quantity'); + $item->save(); + return redirect()->back()->with('success', 'Item updated successfully!'); + } else { + return redirect()->back()->with('error', 'Item not found!'); + } + } else { + return redirect('/login')->with('error', 'Please login to update item!'); + } + } + + + + + + + + public function checkout() diff --git a/resources/views/cart.blade.php b/resources/views/cart.blade.php index e1289fb..27e5a4d 100644 --- a/resources/views/cart.blade.php +++ b/resources/views/cart.blade.php @@ -43,38 +43,9 @@ + + {{--
- @foreach ($cartItems as $item) -