Voyager: Remove last value on belongsToMany relationship

Created on 25 May 2018  路  6Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.5.40
  • Voyager Version: 1.1.1
  • PHP Version: 7.0
  • Database Driver & Version: mysqli / mysqlnd 5.0.12-dev

Description:

If you delete all values from the belongToMany field, one of them is not deleted.

Steps To Reproduce:

Create BelongsToMany Relationship in some Bread.
Add two relations in this entity, save.
Open it, remove relations. Save.
One relations don't removed.

Cause

vendor/tcg/voyager/src/Http/Controllers/Controller.php, line 62.
if ((isset($options->type) && $options->type !== 'belongsToMany') || $row->field !== 'user_belongsto_role_relationship')

Because of the second part of the expression, the condition is always true.
remove this
$row->field !== 'user_belongsto_role_relationship'
from condition - relations work fine.

WTF is this condition here?

Most helpful comment

A smaller bug than the fact that Voyager would break without it.
Also, as @vblinden mentioned, there's a PR waiting to be merged, which completely fixes it

All 6 comments

3112

Its an "emergency-fix" otherwise Voyager would break when submitting your user-profile.
Also please watch your words - thats unnecessary

This emergency fix make a big bug.

A smaller bug than the fact that Voyager would break without it.
Also, as @vblinden mentioned, there's a PR waiting to be merged, which completely fixes it

Fixed in #3016.
Merged into 1.x

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings