a2zwebltd/auditable-relations
Auditable Relations extends Laravel auditing to relationship changes, so attaches, detaches, syncs, and related model updates are captured automatically. Get a clear, queryable history of who changed what and when, without wiring audit logic into every relation by hand.
attach, detach, sync, toggle) are where role grants, permission assignments, team membership, and catalog tagging actually happen. This package closes that specific gap, which makes it a scope decision for any SOC 2 / ISO 27001 / HIPAA-adjacent milestone.MorphToMany attaches, the attach half of toggle(), dropped pivot configuration (withPivot, withTimestamps, using, as, wherePivot), custom pivot classes breaking on type checks. Buying (MIT, free) is cheap; the real cost is verification, not licensing.Consider it when:
owen-it/laravel-auditing and the only gap is relationship-level events — this is additive, not a replacement.MorphToMany, or toggle() — v1.2.0 specifically fixes those, and older versions would silently miss or corrupt them.Look elsewhere when:
sync() in nightly imports or backfills will multiply into two extra SELECTs and a full related-model snapshot per row.For executives: "Our audit log currently answers 'who edited this user record' but not 'who added this person to an admin role.' That second question is the one auditors and incident reviews actually ask, and today we can't answer it from logs. This is a small, free, MIT-licensed Laravel package that closes exactly that gap and nothing more. The license cost is zero and the integration is narrow, but I'd frame it as something we adopt and own rather than a strategic dependency — it's early-stage with a single maintainer. Recommendation: fund a short spike to fork it, pin the version, and write tests against our own relations before it touches a compliance-critical path."
For engineering: Adoption is a trait/wrapper around your existing relations (auditableRelation()) layered on Laravel Auditing. v1.2.0 preserves pivot configuration chained on BelongsToMany, audits MorphToMany attaches and the attach half of toggle(), respects custom using() pivot classes instead of swapping them, and audits pivot saves/deletes transactionally via the new HandlesAuditablePivot trait. It ships a Pest suite and a Laravel Boost guideline, which lowers onboarding cost. Two things to plan for up front: performance — two extra SELECTs per operation plus full related-model storage per audit row, so index and set retention deliberately — and maintenance — 4 stars, zero dependents, so pin the version, fork it into our namespace, and cover our own relation shapes with tests rather than assuming upstream coverage.
How can I help you explore Laravel packages today?