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

[Suggestion] or query methods #50

Open
squatto opened this issue Feb 11, 2021 · 5 comments
Open

[Suggestion] or query methods #50

squatto opened this issue Feb 11, 2021 · 5 comments

Comments

@squatto
Copy link
Contributor

squatto commented Feb 11, 2021

Would it be helpful (and would you consider merging) if I added or methods for each of the query methods? orWhereMeta(), orWhereHasMeta(), and so on. They would be helpful to avoid having to do fun things like this:

->where(fn ($query) => $query->whereMeta('hidden_from_admin', false)
                             ->orWhere(fn ($query) => $query->whereDoesntHaveMeta('hidden_from_admin'))
)

AKA "where the hidden_from_admin meta is false or it doesn't exist"

This instead could be:

->where(fn ($query) => $query->whereMeta('hidden_from_admin', false)
                             ->orWhereDoesntHaveMeta('hidden_from_admin')
)

Or this:

->where(fn ($query) => $query->whereMeta('source_order_id', $searchValue)
                             ->orWhere(fn ($query) => $query->whereMeta('source_order_number', $searchValue))
)

AKA "where the source_order_id or source_order_number meta is $searchValue"

This instead could be:

->where(fn ($query) => $query->whereMeta('source_order_id', $searchValue)
                             ->orWhereMeta('source_order_number', $searchValue)
)

The or methods will essentially just be orWhere() wrappers around the base query methods (like I'm doing above).

Let me know what you think. Thanks!

@frasmage
Copy link
Collaborator

For now, I think the workaround seems simple enough. Could be something to keep in mind if others feel like this would be a useful feature.

@vesper8
Copy link

vesper8 commented Mar 7, 2021

@frasmage @squatto I would very much like to see orWhereMeta added. Without it some of my queries are becoming very long and complex since migrating to metable

@frasmage
Copy link
Collaborator

frasmage commented Mar 7, 2021

If there is enough interest, a pull request is welcome 🙂

@squatto
Copy link
Contributor Author

squatto commented Mar 8, 2021

OK sweet, I'll send something up when I get a minute to put it together 👍🏻

@ghost
Copy link

ghost commented Dec 11, 2022

Any updates on this enhancement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants