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.7] Add orWhere proxy for scopes to Eloquent Builder #27281

merged 1 commit into from Jan 24, 2019


None yet
2 participants
Copy link

erikgaal commented Jan 23, 2019


This PR adds a shorter way of combining Model query scopes using the same technique applied in Laravel's Collections. Currently, combining model scopes with an OR operator adds more complexity in than necessary.

// scopeFoo, scopeBar, scopeBaz on the Model class 
$query->foo()->orWhere(function (Builder $query) {
})->orWhere(function (Builder $query) {

This PR allows chaining of OR's without the Closure in user code, like so.


It follows the same logic as combining regular where and orWhere. The following code examples are thus considered equivalent.

// scopeFoo, scopeBar, scopeBaz on the Model class 
$query->foo()->orWhere(function (Builder $query) {


  1. This PR does not break any existing functionality as far as I know.

  2. I have considered another approach to achieve the same simplicity. It would add the possibility to call query scopes prepended with or, like so. But to my knowledge, this seemed more confusing than the proposed change.


@taylorotwell taylorotwell merged commit 33eff6c into laravel:5.7 Jan 24, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment