文档中的更新父级时间戳方法不起作用
在Comment
模型中添加了protected $touches = ['post'];
,运行如下代码:
$comment = App\Comment::find(1);
$comment->body = 'Edit test!';
$comment->save();
==>查看数据表Post中对应记录的时间戳,并没有更新
使用另一个方法可以更新(可以注释掉$touches属性那一行):
$comment->post->touch();
不知为何前面那种方法不起作用。
推荐文章: