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? (36 h 00 min)

You also get:

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

Already a member? Login here

Alex Gower avatar

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

Manuel Jacquez avatar

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']

Povilas Korop avatar

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.