detach with deleted_at laravel code example
Example: adding soft delete in pivot table
public function groups() {
return $this->belongsToMany(Group::class)
->wherePivot('deleted_at', null)
->withTimestamps();
}
$user->groups
->updateExistingPivot($groupId, ['deleted_at' => Carbon\Carbon::now()]);