Skip to content

[13.x] feat: add orWhereKey and orWhereKeyNot to Eloquent Builder - #61154

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
calebdw:calebdw/push-lyszsmxqtzpx
Aug 13, 2026
Merged

[13.x] feat: add orWhereKey and orWhereKeyNot to Eloquent Builder#61154
taylorotwell merged 1 commit into
laravel:13.xfrom
calebdw:calebdw/push-lyszsmxqtzpx

Conversation

@calebdw

@calebdw calebdw commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Hello!

There's been many, many times where I've wanted to reach for a orWhereKey() method, but it doesn't exist so I've had to completely restructure my query or fallback to the ->orWhereIn('id', ...) that the whereKey() method was generally supposed to replace.

This PR adds both the orWhereKey() and orWhereKeyNot() methods for completeness. The existing whereKey()/whereKeyNot() methods were basically duplicates of each other with a lot of repetitive code, so that's been cleaned up as well.

Note

This is not a BC from the caller's perspective, however, this does change the method signatures so I guess this technically would be a BC if someone extended the Builder class and overrode the whereKey/whereKeyNot methods (but not sure why anyone would do that).

In any case, let me know if it's acceptable to put into 13.x, or if I need to target 14.x

Thanks!

Consolidate whereKey and whereKeyNot into a single method with
$boolean and $not parameters, following the same pattern used by
whereIn/orWhereIn/whereNotIn/orWhereNotIn on the base query builder.

whereKeyNot now delegates to whereKey with $not=true, eliminating
the duplicated key-type checking and array-handling logic.

Add orWhereKey and orWhereKeyNot methods to allow OR-combined
primary key constraints without restructuring queries.
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