Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

touch() Method To Work With updated_at

Premium
1:03

A "quick tip" lesson. Laravel has a few helper methods to update your Eloquent Model updated_at timestamp. For example, on the user Model, you have some users, and you want to update just its updated_at value without touching any other data.

You can use touch() on the Model, which will update only the updated_at field.

Since Laravel 9.25, there's a possibility to use touch() on multiple models with Eloquent query.

Records with an ID bigger than two will be updated, and the result is how many records are updated. In this example, two.


You can also touch a...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…