F
Filament5mo ago
TiBiBa

Prevent allowDuplicates() when using detach action

Hi! We've implement a MorphToMany relationship that allows for a user -> user_roles -> role relationship. The pivot table looks as follows: - user_id - role_id - team_id A user is allowed to have the same role multiple times as long as the team is different. By using allowDuplicates() attaching new records works as expected. However, when attempting to detach records it crashes, as an id column is expected when allowing duplicates. Is there anyway to get this to work? Thanks in advance!
Solution:
Add an auto-incremementing id? Else we have no way of knowing which record to delete unless you adjust the detachh to be a custom detach that matches both the user_id, role_id and team_id
Jump to solution
2 Replies
Solution
toeknee
toeknee5mo ago
Add an auto-incremementing id? Else we have no way of knowing which record to delete unless you adjust the detachh to be a custom detach that matches both the user_id, role_id and team_id
TiBiBa
TiBiBaOP5mo ago
Thanks for your reply! I did just that, made an custom action to match the id's and manually remove the record.
Want results from more Discord servers?
Add your server