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

Adds support for query comparison operators #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jorbascrumps
Copy link

@jorbascrumps jorbascrumps commented May 13, 2022

Resolves #39

Queries can still be performed without explicitly setting an operator:

Entity::where('active', true)->get();

Or queries can have an operator specified:

Entity::where('created_at', '>', Carbon::now())->get();

Queries can even use a combination:

Entity::where('published', true)
    ->where([
        ['numComments', '>', 1],
        'author', 8)
    ])
    ->limit(10)
    ->get();

If an operator is not specified its value is set to = by default. Supported operators are: =, <, >, <=, >=, <>, !=, <=>.

Services will now have access to the column, operator, and value that has been set in the query:

public function getEntities(array $where)
{
    foreach ($where as [$column, $operator, $value]) {
        // ...
    }
}

@jorbascrumps
Copy link
Author

@TZK- Any thoughts on this?

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.

Querying does not support comparison operators
1 participant