📜  laravel 添加多对多 - PHP 代码示例

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

代码示例1
You should pass an array of user IDs to the attach() method.

For convenience, attach and detach also accept arrays of IDs as input

Change your code to:

$team = \App\Team::findOrFail($request->team_id);
$team->teamMembers()->attach($request->members_id);