Laravel save / update many to many relationship

后端 未结 4 854
日久生厌
日久生厌 2020-12-07 07:28

Can anyone help me on how to save many to many relationship? I have tasks, user can have many tasks and task can have many users (many to many), What I want to achieve is th

4条回答
  •  生来不讨喜
    2020-12-07 07:44

    The sync function obliterates the exiting relationships and makes your array the entire list of relations. You want attach instead to add relations without removing others.

提交回复
热议问题