Skip to content

[12.x] Add increment and decrement methods to Context #54976

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

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

mattmcdev
Copy link
Contributor

@mattmcdev mattmcdev commented Mar 11, 2025

This PR proposes adding increment and decrement methods to Context.

This simplifies keeping track of a counter, e.g. number of records added, number of requests made, etc.

@henzeb
Copy link
Contributor

henzeb commented Mar 11, 2025

i'd opt for increment, like the Cache facade and Eloquent models have?

@mattmcdev mattmcdev changed the title [12.x] Add counter method to Context [12.x] Add count method to Context Mar 11, 2025
@mattmcdev mattmcdev changed the title [12.x] Add count method to Context [12.x] Add increment and decrement methods to Context Mar 11, 2025
@mattmcdev
Copy link
Contributor Author

i'd opt for increment, like the Cache facade and Eloquent models have?

Agreed

@taylorotwell taylorotwell merged commit 9b060d8 into laravel:12.x Mar 12, 2025
39 checks passed
@christophrumpel
Copy link
Contributor

@mattmcdev Hey 👋

Do you have a real-world example of how you would use these new methods? Need a good one for the next Whats New video please :-)

@mattmcdev
Copy link
Contributor Author

@mattmcdev Hey 👋

Do you have a real-world example of how you would use these new methods? Need a good one for the next Whats New video please :-)

Yep - using Laravel Excel with queued chunked imports, can easily keep track of the number of records inserted throughout that import job.

@christophrumpel
Copy link
Contributor

Ah, that's interesting, 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.

5 participants