Can we make new query method, whenWhere? #49190
Unanswered
yogeshgalav
asked this question in
Ideas
Replies: 2 comments 2 replies
-
Not sure I can understand the difference here... The second one simply seem to collapse the first, and could easily be done with when. I may be missing something here? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Is this different to this? User::query()
->when(true, fn ($query) => $query->where('name', 'like', '%Taylor%')->orWhere('name', 'like', '%James%'))
->get(); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes I need to define two closures first for when and second for where,
and pass data in both,
it would be better if a single function would be available.
consider the following example.
the same code would be shorter and easy to read if it could be converted to following.
Beta Was this translation helpful? Give feedback.
All reactions