Model methods that take arrays as arguments should also be allowed to take Collections #43389
Unanswered
BrekiTomasson
asked this question in
Ideas
Replies: 1 comment
-
This one would be a breaking change if was added at the minor release. I'm not sure it wouldn't introduce bugs across the codebase. Will require a code review in a lot of places definitely, so I don't see it earlier than in Laravel |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Say I have the following:
If I wanted to update the
null
fields, I can do so using the instantiated variable or directly on the Model class, but I have to use an array:But I can't do this:
I know it's as easy as doing
$country->update($changes->toArray())
, of course, but it's not immediately obvious why updating a Model using an "arrayable" collection like this shouldn't be handled natively. Under the hood, it could be as simple as rewriting the methods inIlluminate\Database\Eloquent
to something like (usingupdate()
as an example):Beta Was this translation helpful? Give feedback.
All reactions