Pass $mode into the has/doesn't have query builder methods #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request changes the builder method calls to account for the $mode parameter.
->whereDoesntHave()
uses->doesntHave()
under the hood (https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Builder.php#L722) which allows passing an "or" or "and" value. Laravel calls this the 'operator'. This package calls this the 'mode'.->whereHas()
uses->has()
under the hood (https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Builder.php#L710) which allows passing the operator/mode.The intended behavior when passing ?mode=or is that ALL filters are applied in DISJUNCTION. Currently, the behavior is using mode=or for parameters that exist on the model and mode=and for relation parameters which is unintended.
Currently, the behavior is the following
?user:first_name=John&user:last_name=Smith&mode=or
select * from providers where (exists (select * from users where providers.user_id = users.id and (first_name = John)) AND exists (select * from users where providers.user_id = users.id and (last_name = 'Smith')))
This pull request will change the query to the following
?user:first_name=John&user:last_name=Smith&mode=or
select * from providers where (exists (select * from users where providers.user_id = users.id and (first_name = John)) OR exists (select * from users where providers.user_id = users.id and (last_name = 'Smith')))