Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $items = $this->find();
- $itemsToDuplicate = $items->filter(function ($item) {
- return $item->isDebit && $item->isCredit;
- });
- // debug(spl_object_hash($items->toArray()[0]));
- // debug(spl_object_hash($itemsToDuplicate->toArray()[0]));
- // they are the same
- $items = $items->map(function ($item) {
- if ($item->isDebit) {
- $item->isCredit = false;
- }
- return $item;
- });
- $items = $items->append($itemsToDuplicate);
- // $itemsToDuplicate is not appended
Add Comment
Please, Sign In to add comment