illuminatech/sync-many-attribute
Laravel package for synchronizing many-to-many related records and their attributes through a single model. Save related model attributes, including pivot data, using familiar form binding and validation, simplifying complex multi-record editing without custom sync logic.
$model->update($request->validated()) just works. The decision it supports is: do we standardize this pattern once, or let every feature team reinvent it and get the null vs. [] semantics subtly different?sync() calls in controllers frequently get this wrong, which is how a PATCH request silently wipes a record's tags. Adoption here is a correctness decision, not just a tidiness one.Adopt when several of these hold:
Look elsewhere — or just write the 40 lines yourself — when:
assigned_at, ordering), or you need custom Pivot models, you are outside the happy path. Use syncWithPivotValues() directly.NOASSERTION, meaning no recognizable standard license was detected. Do not ship it into a commercial product until legal has read the actual license file. This is a hard blocker, not a footnote.To executives: This is a small developer-productivity utility, not a product feature. It removes repetitive, error-prone code from the admin tooling we build constantly, and it eliminates an entire class of "saved the form, lost the tags" bugs. Cost of adoption is hours, not weeks. Cost of the dependency is a maintained open-source library with a single author — manageable because it's small enough to replace in-house if needed. No customer-visible change, no infrastructure change, no schema change.
To engineering: One trait on the model, one virtual attribute per relation, and sync happens on save. Keeps controllers thin, keeps the diff-vs-sync logic out of every request class, and gets the null-vs-empty semantics right once. Constraints to be honest about: no pivot attributes, no change events, one maintainer, license needs a look before merge. Mitigation: wrap it behind a base model or trait so the third-party import appears in exactly one file, pin the version, and keep a copy of the upstream source in the repo if your policy requires forkability. If any of the constraints bite, the fallback is a small in-house trait — roughly a day of work — so this is a low-regret decision either way.
How can I help you explore Laravel packages today?