I'm having a bit of trouble with a presenter i'm writing. In essence, I want to run a function to organise a bunch of data once, then let other functions utilise that organised data without altering it.
I've mocked up a simple example: http://laravel.io/bin/REkO8
If I run $payslip->present()->paymentsAbove(10)
it alters each contract->transactions
entity within $itemsByContract
, so if I were to run $payslip->present()->paymentsBelow(10)
it wouldn't return any items because the first function already filtered them out.
Is there anything I can do short of running something like this each time I want to use one of the functions?
private function cloneStuff()
{
$_items = $this->itemsByContract;
$items = new Collection;
foreach ($_items as $_item) {
$item = clone $_item;
$items->push($item);
}
return $items;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community