title: Remove row from pagination inside of transform
body: <p>I have a variable that is a pagination object</p>
  
  <pre><code>$pagination
  </code></pre>
  
  <p>I am changing things inside of it using transform</p>
  
  <pre><code>$pagination-&gt;getCollection()-&gt;transform(function ($item, $key) use(&amp;$data, &amp;$pagination) {
      $item-&gt;foo = 'bar';
  }
  </code></pre>
  
  <p>I want to remove an item from the pagination if it meets a certain condition. I don't want it removed until after I've been able to use the data. Following is an example.</p>
  
  <pre><code>$pagination-&gt;getCollection()-&gt;transform(function ($item, $key) use(&amp;$data, &amp;$pagination) {
      $data[] = $item-&gt;foo;
      if ($item-&gt;foo === 'bar') {
          $item-&gt;remove();
      }
  }
  </code></pre>
  
  <p>I've also tried using <code>$pagination-&gt;getCollection()-&gt;forget($key);</code> inside of the transform</p>
  
  <pre><code>$pagination-&gt;getCollection()-&gt;transform(function ($item, $key) use(&amp;$data, &amp;$pagination) {
      $data[] = $item-&gt;foo;
      if ($item-&gt;foo === 'bar') {
          $pagination-&gt;getCollection()-&gt;forget($key);
      }
  }
  </code></pre>
  
  <p>That's from this question. </p>
  
  <p><a href="https://stackoverflow.com/questions/37588515/how-to-unset-remove-a-collection-element-after-fetching-it/37588625">How to unset (remove) a collection element after fetching it?</a></p>
  
  <p>I'm guessing the fact I'm dealing with a pagination may be making these answers not apply to my situation.</p>