5 years ago

Many to Many relation with unique records in pivot

Posted 5 years ago by francois

Hi, When you use attach() method in a many to many relation, you can add this record multiple times.

Here is an example of the pivot table

id, model1, model2

1, 10, 11

2, 10, 11

And, I'd like to forbidden this behavior.

Sync() method can't be used in my case. Thanks.

Please sign in or create an account to participate in this conversation.