📜  在数据透视表中添加软删除 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:43.860000             🧑  作者: Mango

代码示例1
public function groups() {
    return $this->belongsToMany(Group::class)
    ->wherePivot('deleted_at', null)
    ->withTimestamps();
}

$user->groups
    ->updateExistingPivot($groupId, ['deleted_at' => Carbon\Carbon::now()]);