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

Allow searching meta fields by LIKE. #430

Merged
merged 7 commits into from
Nov 30, 2018
Merged

Conversation

bluehaoran
Copy link
Contributor

Allow users to do a like search on meta values.

I couldn't figure out an elegant way to do this with Corcel as it currently is, so I added this for our own use.

My current use-cases are doing a case-insensitive search on posts by category, but I can also see wanting to retrieve by "category%".

Usage: you can now retrieve by meta, e.g.:

User::hasMeta(['first_name' => 'ADAM'])->get();
User::hasMeta(['full_name' => 'Adam%'])->get();

Added tests for this (hasMetaLike()) and hasMeta.

(Duplicates and supersedes #417.)

@jgrossi
Copy link
Member

jgrossi commented Nov 26, 2018

Hi @bluehaoran! first thanks for the PR! I pushed some changes just to improve tests readability and also avoid code duplication when creating scopeHasMetaLike() method, ok? take a look and let me know what you think of them, please. thanks! 😎💪

@jgrossi
Copy link
Member

jgrossi commented Nov 26, 2018

@bluehaoran also, can you add that to the README (documentation), please? thanks

@bluehaoran
Copy link
Contributor Author

Hi @jgrossi, changes look fine! No objections. Updated the docs; hope you don't mind me using your name :)

README.md Outdated Show resolved Hide resolved
@jgrossi jgrossi merged commit 1775fc4 into corcel:2.7 Nov 30, 2018
@bluehaoran bluehaoran deleted the metalike branch December 2, 2018 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants