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 without_events method to ObserveEvents class. This feature upda… #693

Merged
merged 2 commits into from
Jun 6, 2022
Merged

Added without_events method to ObserveEvents class. This feature upda… #693

merged 2 commits into from
Jun 6, 2022

Conversation

JarriqTheTechie
Copy link
Contributor

@JarriqTheTechie JarriqTheTechie commented May 27, 2022

Added with_events & without_events method to mute events.

Example usage.

user = User.without_events().create({"name": "Walter Emert", "email": "phill"})
user.with_events()
user.name = "Bobby Turner"
user.save()

In the above example we muted the events before creating the users then unmuted them before saving the mutated user.

…te works by setting the __has_events__ attribute on the model to False. If attribute is set to true then events will run as normal. If set to false will bypass all observable events.
@JarriqTheTechie
Copy link
Contributor Author

@josephmancuso ready for review.

Added additional method for reactivating events
@josephmancuso josephmancuso merged commit 3e6fd79 into MasoniteFramework:2.0 Jun 6, 2022
@JarriqTheTechie JarriqTheTechie deleted the feature/without_events branch June 8, 2022 03:10
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