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

Added two new "field" types: has and scope. This grants the ability t… #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HenriqueSPin
Copy link

@HenriqueSPin HenriqueSPin commented Jan 18, 2019

Added two new "field" types: has and scope. This grants the ability to query the eloquent model with the has() and/or to add a model scope.

Usage:

Eloquent:
Post::hotAndPopular()->get();

With arrayQuery:
Post::arrayQuery([ "scopes" => "hotAndPopular" ])->get();

You can even add N scopes like that:
Post::arrayQuery([ "scopes" => ["whatsNew", "hotAndPopular"] ])->get();

Same goes to query relationship existence:

Eloquent:
Post::has("comments")->get();

With arrayQuery:
Post::arrayQuery([ "has" => "comments" ])->get();

You can also add N relationships like that:
Post::arrayQuery([ "has" => ["comments", "author"] ])->get();

…o query the eloquent model with the has(<relationship>) and/or to add a model scope.

E.g.:

Eloquent:
Post::hotAndPopular()->get();

With arrayQuery:
Post::arrayQuery([ "scope" => "hotAndPopular" ])->get();

You can even add N scopes like that:
Post::arrayQuery([ "scope" => ["whatsNew", "hotAndPopular"] ])->get();

Same goes to query relationship existence:

Eloquent:
Post::has("comments")->get();

With arrayQuery:
Post::arrayQuery([ "has" => "comments" ])->get();

You can also add N relationships like that:
Post::arrayQuery([ "has" => ["comments", "author"] ])->get();
@HenriqueSPin
Copy link
Author

@williamoliveira Could you please provide some feedback?

@williamoliveira
Copy link
Owner

I do not work with PHP for some time I cannot test it manually right now, but the feature seems fine.
Could you just implement some automated tests? they are very easy to write in this lib.

@HenriqueSPin
Copy link
Author

@williamoliveira Sure! I'll get to it.
BTW I've tried to reach you via LinkedIn. Can you please take a look?

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.

3 participants