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

[12.x] Refactor Query Builder: Extract shared logic from whereAny and whereAll into a reusable method #55290

Closed
wants to merge 2 commits into from

Conversation

ezequidias
Copy link

@ezequidias ezequidias commented Apr 6, 2025

This PR refactors the Query\Builder class to eliminate duplicated logic between the whereAny and whereAll methods.

Both methods were doing the same thing internally — looping over the columns and applying a where clause — with only the boolean (or vs and) being different. That repeated logic has now been pulled into a new internal method: addNestedWhereGroup.

Before

Both whereAny and whereAll had almost identical code blocks for building nested conditions. This made the code harder to maintain and more error-prone when changes were needed.

After

Now both methods delegate to addNestedWhereGroup, which handles the common logic. This keeps things cleaner, more maintainable, and easier to reason about.

@ezequidias ezequidias marked this pull request as draft April 6, 2025 04:14
@ezequidias ezequidias marked this pull request as ready for review April 7, 2025 00:10
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

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.

2 participants