laravel更新、删除中间表数据

$user->stores()->attach([1,2,3]);//插入
$user->stores()->detach();//全部删除
$user->stores()->sync([1,2]);//全部删除后再次插入

发表评论

电子邮件地址不会被公开。

This site uses Akismet to reduce spam. Learn how your comment data is processed.