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