在laravel 4中更新父级时触摸子时间戳

时间:2014-06-18 10:43:11

标签: php laravel laravel-4

W.r.t laravel doc #Touching Parent Timestamps

class Comment extends Eloquent 
  {

    protected $touches = array('post'); // my concern with "touches"

    public function post()
    {
         return $this->belongsTo('Post');
    }

 }

因此,当评论模型更新时,会自动触摸拥有帖子的updated_at时间戳。

我有一种情况需要让它反向,比如发布更新后自动更新评论的那篇帖子的update_at。

无论如何使用Eloquent ORM进行此操作?

0 个答案:

没有答案