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

Scope retrieving models with operator #89

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

erikn69
Copy link
Contributor

@erikn69 erikn69 commented Oct 27, 2021

If you only want to search on a single custom attribute with a custom operator, you can use the modelScope like this

// returns all models that have a schemaless attribute `name` starting with `value`
$yourModel->withExtraAttributes('name', 'LIKE', 'value%')->get();
// returns all models that have a schemaless attribute `name` different that `value`
$yourModel->withExtraAttributes('name', '!=', 'value')->get();
// returns all models that have a schemaless attribute `number` greater than `10`
$yourModel->withExtraAttributes('number', '>', 10)->get();

@erikn69 erikn69 force-pushed the scope_with_operator branch from bdf1768 to 2d69725 Compare November 8, 2021 13:36
@erikn69
Copy link
Contributor Author

erikn69 commented Nov 8, 2021

@freekmurze rebase with fixed tests

@freekmurze freekmurze merged commit f731d35 into spatie:main Nov 8, 2021
@freekmurze
Copy link
Member

Thanks!

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