How to update parent timestamp when a child is updated in Laravel
Categorized as Laravel
Laravel quick tip – you can update the parent model timestamp when a child has got updated. All you have to do is define a property called $touches, assuming you have a belongsTo or belongsToMany relationship.
class Comment extends Model
{
protected $touches = ['post'];
public function post()
{
return $this->belongsTo(Post::class);
}
}