I have mulutiselect option enabled in select html code, my frontend look like this:
For example if user unselect some option and select other how can I update it in database, any idea?
I have mulutiselect option enabled in select html code, my frontend look like this:
For example if user unselect some option and select other how can I update it in database, any idea?
If you have ManyToMany
relationships between say Group
and Project
you can use sync()
method to maintain association as below,
$group->projects()->sync([$projId1, $projId2]);
Above will remove all previous association between current group($group
) and projects and associates newly supplied projects i.e. $projId1, $projId2
.
If you want to maintain previous associations pass false
as a second argument in sync()
as below,
$group->projects()->sync([$projId1, $projId2], false);
Above code will maintain previous Group
and Project
association and will also associate passed projects.