vendredi 28 août 2015

How to increment an item in Laravel collection?

$collection = collect([
    1 => ['sum' => 0, 'eaters' => 0],
    2 => ['sum' => 0, 'eaters' => 0],
    3 => ['sum' => 0, 'eaters' => 0],
    4 => ['sum' => 0, 'eaters' => 0],
    5 => ['sum' => 0, 'eaters' => 0]
]);

$collection[1]['sum'] += 5;

When i try to add something i get Indirect modification of overloaded element of Illuminate\Support\Collection has no effect. I think this is something to deal with ArrayAccess, but i'm not familiar with this...



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1LGmpfF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire