A Laravel service for replacing an existing dataset with a new dataset - updating, inserting & deleting records as efficiently as possible to transform the existing database state into the new desired state. This works for any adhoc set of records, or on a HasMany relationship.
A common scenario with saving or syncing data is the need to replace an existing set of records with an updated set - which may include new or removed items.
Laravel provides a sync method for many-to-many relationships which is a similar concept but only replaces the relationships - requiring you to know the IDs of the records you want to attach to, and not impacting the underlying data. It also only works on the relationships of a single parent at a time, whereas we may want to sync records for a large group of parents in one go.
Laravel also provides an upsert method which is a fast