Answers for "laravel add many to many"

PHP
0

laravel add many to many

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 = AppTeam::findOrFail($request->team_id);
$team->teamMembers()->attach($request->members_id);
Posted by: Guest on January-06-2022

Code answers related to "laravel add many to many"

Browse Popular Code Answers by Language