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

[9.x] Add ability to Model::query()->touch() to mass update timestamps #43665

Merged
merged 2 commits into from
Aug 15, 2022
Merged

[9.x] Add ability to Model::query()->touch() to mass update timestamps #43665

merged 2 commits into from
Aug 15, 2022

Conversation

stevebauman
Copy link
Contributor

This PR adds the touch($column = null) method to the Eloquent query builder.

This is a convenience method, allowing you to mass update a model's timestamp in the database table with or without query constraints:

Mass touching the updated at column:

$touched = User::query()->touch();

Mass touching the updated at column with constraints:

$touched = User::where('email', 'like', '%@company.com')->touch();

Mass touching a specific column:

$published = Post::query()->touch('published_at');

It behaves identically to $model->touch(), and accepts the same method argument.

Let me know your thoughts! Thanks for your time 🙏

@taylorotwell taylorotwell merged commit 07aae35 into laravel:9.x Aug 15, 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.

3 participants