Closed wilianx7 closed 5 months ago
It's because I have published the master branch of my fork on Packagist. So I created another branch for this PR.
also syncWithPivotValues
, syncWithoutDetaching
are missing
https://laravel.com/docs/9.x/eloquent-relationships#syncing-associations
Hello guys.
In my API I have a situation where I need to provide a BelongsToMany relationship with some conditions to Audit Attach, Detach and Sync.
This situation occurs because my pivot table has many pivot columns that need to be conditioned when I do an Attach/Detach/Sync.
Nowadays I can't do this, as these methods only accept the name of the relationship (without conditions). So I made this PR with a new optional parameter
callback
.Example use case:
In this case, I just want to sync the serviceTypes relationship in my pivot table, where the pivot columns match the respective company_id and tenancy_id values. The other data in the pivot table remained unchanged.