使用同步方法laravel在数据透视图中进行软删除 [英] Soft deleting in pivot with sync method laravel
本文介绍了使用同步方法laravel在数据透视图中进行软删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想同步用户表中的某些关系,并且我不想Laravel删除该行,我想对该行进行一些更新(例如填充Deleted_at), 到目前为止,我进行了搜索,发现的唯一解决方案是重写同步方法.
I want sync some relation in User's Table and I don't want to Laravel delete the row, I want make some updates on that row (Like fill the deleted_at), I searched so far and only solution i found is that to override sync method.
那么我如何覆盖sync方法来更新行?
So how i can override the sync method to update the row?
或者是该问题的另一种解决方案?
Or whats another solution for this problem?
我知道问题出在detach
方法上,如果我可以覆盖detach
,它将解决!
EDITED: I know the problem is with detach
method, If i could override the detach
It will be solved!
谢谢
推荐答案
我认为您正在寻找此方法.
I think you were looking for this method.
$user->your_relation()->updateExistingPivot($userid, ['deleted_at' => $date]);
这篇关于使用同步方法laravel在数据透视图中进行软删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文