Soft deleting in pivot with sync method laravel

别等时光非礼了梦想. 提交于 2019-12-22 08:59:44

问题


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.

So how i can override the sync method to update the row?

Or whats another solution for this problem?

EDITED: I know the problem is with detach method, If i could override the detach It will be solved!

Thanks


回答1:


I think you were looking for this method.

$user->your_relation()->updateExistingPivot($userid, ['deleted_at' => $date]);


来源:https://stackoverflow.com/questions/47843469/soft-deleting-in-pivot-with-sync-method-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!