Skip to main content

touch() Method To Work With updated_at

Premium
3:47

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 33 min)

You also get:

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

Already a member? Login here

Comments & Discussion

AG
Alex Gower ✓ Link copied!

Thanks! This concept has become more important to me when I have been indexing data using scout to rebuild the document

MJ
Manuel Jacquez ✓ Link copied!

Hi there! I have tried this on a "normal" haveMany/belongsTo relationship, lets say Post has many Comment and it works fine, but when the relationship is a Morph relationship (using model_id and model_type fields), it doesnt seem to work... documentation doesnt say anything about touching timestamps in morph relationships. I solved that "manually" with model events but i dont know if iI'm missing something when trying to touch timestamps in a morph. how do you indicate the parent model? protected $touches = ['model']

PK
Povilas Korop ✓ Link copied!

I've never used it in a Morph relationship, I don't think it would work, I also haven't seen it in the docs. So you were right to build it manually with Events.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.