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 query helpers for event properties #326

Merged
merged 2 commits into from
Mar 4, 2022

Conversation

aidan-casey
Copy link
Contributor

@aidan-casey aidan-casey commented Mar 2, 2022

This PR adds two methods wherePropertyIs() and wherePropertyIsNot() to the stored event query builder. These allow you to perform lookups against event properties and utilize the whereJsonContains methods. As an example, we have had to use this when querying for all events for a company.

Example:

EloquentStoredEvent::query()
    ->whereEvent(CompanyOptedOutOfEmails::class)
    ->wherePropertyIs('companyId', 'ABC-123-XYZ')
    ->get();

@brendt
Copy link
Collaborator

brendt commented Mar 3, 2022

Great addition. Two questions:

  • Should we use whereProperty or wherePropertyIs ? The PR uses the first, but your comment mentions the latter. I prefer the latter one.
  • Can you add a test for this?

@aidan-casey
Copy link
Contributor Author

  1. Good catch. My intention had been wherePropertyIs for consistency, but as you mention that's not reflected in the PR. I'll update that today.

  2. Definitely. 👍🏼

@aidan-casey
Copy link
Contributor Author

@brendt - Updated with changes. Let me know what you think.

@brendt brendt merged commit f0560c4 into spatie:main Mar 4, 2022
@brendt
Copy link
Collaborator

brendt commented Mar 4, 2022

This is good, I'll release it together with #327

@brendt
Copy link
Collaborator

brendt commented Mar 4, 2022

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