-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Add merge()
function to ValidatedInput
#38640
Conversation
I don't think this is wanted. The point of ValidatedInput is that it's data that's been validated and data you merge in may not be. I realize |
If this class is intended to be immutable then shouldn't the set method throw an exception rather than trying to set the value? That way it's still complies with ArrayAccess but keeps with the intended design goal. |
@garygreen I agree. I don't know though why it was added. |
I honestly don't mind this that much... sometimes you may need to throw a few default values into the validated data if you are going to pass it straight to a model creation method. |
No worries @taylorotwell. Was just wondering if you intended it to be mutable. |
Just a thought: would it be better if this method was used that a new non-ValidatedInput object was returned? Like a collection instance? |
@driesvints then Eloquent would no longer be able to use it for mass assignment. |
It's kind of a shame this class doesn't have a clearer design goal - it's essentially just a stripped back collection but called |
* Add `merge()` function * Add test for `merge()` function * Fix the test * Update ValidatedInput.php * Update ValidatedInputTest.php Co-authored-by: Taylor Otwell <[email protected]>
This PR will add the ability to merge items to validated inputs. As an example
Previously you can't do this when using Form Request, you can't merge any data to the returned data from
validated()
.