I have a pivot table employee_project. In it, I have id, employee_id and project_id.
Each project has an Account Manager and a Project Manager. So in my form I have name (for the project) which should add the id to project_id and I also have am_id and pm_id, which refer to employee_id. How do I get these IDs into the pivot table since they are named differently than employee_id?
This does not work:
$p = Project::create($request->all());
Naming doesnot matter.The values inside array are employee_id anyway.
$p->employees()->sync([1,2]); should work.
You are passing
pm_id as string?