Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
2.99k stars 880 forks source link

Allow BelongsToMany/MorphToMany to store duplicate pivots #5538

Closed pxpm closed 3 weeks ago

pxpm commented 1 month ago

WHY

BEFORE - What was wrong? What was happening before this PR?

As several people requested previously, there is sometimes the need to allow the saving of duplicated pivots. Lately resurface by an user trying to fix that issue in #5535

AFTER - What is happening after this PR?

This PR introduces the ability for developers to define on their field: allow_duplicate_pivots => true, and Backpack will save the duplicated pivots. For that to work, developer need to ensure the pivot table has an "id" column, that will be added to the docs.

Is it a breaking change?

From this PR POV - NO

How can we test the before & after?

I added tests for saving with and without duplicates.