Laravel 5.4 LengthAwarePaginator : <p>My brain suddenly crashed on this one. Anyone care to help me is highly appreciated.</p>

<p>This is LengthAwarepaginator in laravel 5.4</p>

<p>Here is the code.</p>

<pre><code>$collection = [];

            foreach ($maincategories-&gt;merchantCategory as $merchantCat) {

               foreach ($merchantCat-&gt;merchantSubcategory as $merchantSub) {

                   foreach($merchantSub-&gt;products as $products){

                        $collection[] = $products;
                   }
               }
            }

            $paginate = new LengthAwarePaginator($collection, count($collection), 10, 1, ['path'=&gt;url('api/products')]);

            dd($paginate);
</code></pre>

<p>It displays perfectly but the problem is the items is 100. That's all my items and I specify it correctly. I need to display only 10.</p>

<p>Base on LengthAwarePaginator constructor. Here is the reference.</p>

<pre><code>public function __construct($items, $total, $perPage, $currentPage = null, array $options = [])
</code></pre>

<p>Here is the screen shot.</p>

<p><a href="https://i.stack.imgur.com/nUNHk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nUNHk.png" alt="enter image description here"></a></p>

<p>Where did I go wrong? TY</p>
