Guest User

Untitled

a guest
Oct 8th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. $items = $this->find();
  3. $itemsToDuplicate = $items->filter(function ($item) {
  4.    return $item->isDebit && $item->isCredit;
  5. });
  6. // debug(spl_object_hash($items->toArray()[0]));
  7. // debug(spl_object_hash($itemsToDuplicate->toArray()[0]));
  8. // they are the same
  9.  
  10. $items = $items->map(function ($item) {
  11.    if ($item->isDebit) {
  12.       $item->isCredit = false;
  13.    }
  14.    return $item;
  15. });
  16.  
  17. $items = $items->append($itemsToDuplicate);
  18. // $itemsToDuplicate is not appended
Add Comment
Please, Sign In to add comment