$cartItems
contains all the rows of products from database and I am using this inside a blade file.
I want to pass this $cartItems
back to a controller from this blade file
Note: $cartItems
is from index()
function in a controller like below.
$cartItems = DB::table('products')->whereIn('id', $cartItemsArray)->get();
return view('cart.index', compact('cartItems')
Below is my code.
index.blade.php
<a href="{{route('cart.checkout',$cartItems)}}" class="site-btn">Proceed to checkout</a>
web.php
Route::get('/cart/checkout/{cartItems}', 'CartController@checkout')->name('cart.checkout')->middleware('auth');
CartController.php
public function checkout($cartItems)
{
dd($cartItems);
return view('cart.checkout');
}
The error I am getting is,
Missing required parameters for [Route: cart.checkout] [URI: cart/checkout/{cartItems}]. (View: E:\github\LARAVEL\Deal-Ocean\resources\views\cart\index.blade.php)