Skip to content
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

[5.3] Adds an Intersect Method on the Request Class #13162

Closed

Conversation

AdenFraser
Copy link
Contributor

Allows intersection of request input with provided array of input keys or method arguments.

@taylorotwell
Copy link
Member

Is this different than $request->only($keys)?

@AdenFraser
Copy link
Contributor Author

$request->only($keys) returns null for $keys which are not provided by the form (either due to the inputs not existing, checkbox not being filled, disabled or whatever other reason).

Returning null for values which shouldn't be updated isn't particularly helpful on update methods as the existing value is then nulled.

@taylorotwell
Copy link
Member

So could the implement of intersect under the hood simply be:

return array_filter($this->only($keys));

@AdenFraser AdenFraser force-pushed the IlluminateRequestIntersectMethod branch from fc09dec to 897de68 Compare April 14, 2016 14:33
@AdenFraser
Copy link
Contributor Author

That's a lot cleaner actually!

Allows intersection of request input with provided array of input keys
(or method arguments).
@GrahamCampbell GrahamCampbell changed the title Adds an Intersect Method on the Request Class [5.3] Adds an Intersect Method on the Request Class Apr 14, 2016
@GrahamCampbell
Copy link
Member

Please send to 5.2. ;)

@AdenFraser
Copy link
Contributor Author

There you go - #13167

@GrahamCampbell
Copy link
Member

Keeping this open incase Taylor wants this on 5.3 only.

@athahersirnaik
Copy link

Great PR. Had done this in base DB repository of my codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants