Replies: 3 comments 9 replies
-
I'd say also add a |
Beta Was this translation helpful? Give feedback.
0 replies
-
This seems a nice addition! |
Beta Was this translation helpful? Give feedback.
9 replies
-
Very nice addition! |
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.
-
Hi,
I was wondering if there are any options regarding updating a model, but only fill the fields of that exists on the model and that do not have a existing value.
So for example I have user model that has these fields;
And I have an array like;
My goal is to only update the first_name field, since that is the only one empty.
If I call the
$user->update($form_data)
function with the data, it will overwrite the last_name & give an error on phone_number.Which I don't want, but I can not find any function for this in the docs.
So if there is no easy solution, I prose a function like
$user->updateMissing($form_data)
.Which will check if the attributes exists in the model & updates only the values of the empty keys.
This function works for me, optional is an extra parameter / function to call it quietly.
Or should this be like an optional parameter in the update function?
Is the above function something I could propose as a PR?
If so, are there someone that can help me with the tests I should write?
If not, why not?
Thanks for your help!
;-)
Beta Was this translation helpful? Give feedback.
All reactions