我在 Post 和 User 之间有一个 hasAndBelongsToMany 关系,称为“订阅”。(而不是posts_users)它包含user_id 和post_id。
我让它工作,但是当我更新 Post 模型的字段时,记录会从 Subscriptions 表中删除。为什么会这样?
更新是这样的(在我的 Post 模型中):
public function markAsRead(){
$this->read(null, $this->id);
$this->set('user_read', 1);
return $this->save();
}
谢谢。