I created a collection in Laravel using:
$collection = new Collection;
Then I proceeded to push multiple items (all of the same model type) into that collection:
$item = $items->first(function($item) {
return $item->field == "value";
});
$collection->push($item);
And finally, I'm attempting to update all of the records that are now in $collection by using $collection->update() or $collection->save() but I'm receiving the follow error:
"Method Illuminate\Support\Collection::update does not exist."
But since I'm using new Collection (and I've also tried collect()), and I'm calling update() non-statically, I was not expecting this error.
How can I update my database records in $collection all at once? Alternatively, is there a way to "queue" up changes on multiple different child objects that will not sacrifice performance?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2UJVre1
via IFTTT
Aucun commentaire:
Enregistrer un commentaire