如何在 laravel 的 belongstomany 关系中传播更新
How to propagate update in belongstomany relationship in laravel
我有两个模型 Shelf、Book 和 Quote
class Shelf extends Eloquent {
public function quotes()
{
return $this->belongsToMany('Book');
}
}
class Book extends Eloquent {
protected $touches = array('shelfs');
public function quotes()
{
return $this->belongsToMany('Quote');
}
public function shelfs()
{
return $this->belongsToMany('Shelf');
}
}
class Quote extends Eloquent {
protected $touches = array('books');
public function books()
{
return $this->belongsToMany('Book')->withTimestamps();
}
}
当我更新 Qoute 模型时,Qout 模型 table 中的 updated_at 被更新,但 Shelf 模型没有。
我是不是做错了什么?
提前致谢
我有两个模型 Shelf、Book 和 Quote
class Shelf extends Eloquent {
public function quotes()
{
return $this->belongsToMany('Book');
}
}
class Book extends Eloquent {
protected $touches = array('shelfs');
public function quotes()
{
return $this->belongsToMany('Quote');
}
public function shelfs()
{
return $this->belongsToMany('Shelf');
}
}
class Quote extends Eloquent {
protected $touches = array('books');
public function books()
{
return $this->belongsToMany('Book')->withTimestamps();
}
}
当我更新 Qoute 模型时,Qout 模型 table 中的 updated_at 被更新,但 Shelf 模型没有。
我是不是做错了什么? 提前致谢