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.
Architecture fit. The package is a thin extension layer over owen-it/laravel-auditing rather than a standalone auditing system. It hooks into Eloquent's relationship lifecycle (attach, detach, sync, toggle) via an auditableRelation() wrapper and custom pivot models (AuditablePivot, AuditableMorphPivot, plus the new HandlesAuditablePivot trait). Architecturally this is the right shape: it delegates persistence and audit formatting to Laravel Auditing and only fills the pivot-change gap that the parent package leaves. The concern is that this gap is filled by intercepting Eloquent internals (pivot events, pivot class substitution, MorphToMany), which is inherently version-sensitive.
Integration feasibility. Feasible for teams already running Laravel Auditing on Eloquent models with BelongsToMany/MorphToMany pivots (roles, permissions, tags, memberships). It is not a drop-in: relationships must be opted in through auditableRelation(), and pivot classes must either extend AuditablePivot/AuditableMorphPivot or be handled via using(). The v1.2.0 fixes show the integration surface is wider than the README implies — chained withPivot(), withTimestamps(), as(), wherePivot(), query constraints, custom pivot classes, and MorphToMany attach all had correctness gaps until recently.
Technical risk.
wherePivot() constraints, pivot class swapping producing TypeError, unaudited MorphToMany attach). That is a warning that the audit contract was not fully correct in earlier releases.SELECTs per operation and full related model storage. For sync() on large sets this multiplies linearly and bloats the audit table.Key questions.
owen-it/laravel-auditing major is required, and what happens on a parent-package upgrade?DB::table(...)->attach, raw deletes) or only Eloquent relationship calls?syncWithoutDetaching, updateExistingPivot, and toggle (detach half) represented in the audit trail?Stack fit. Assumes Laravel (Eloquent) + owen-it/laravel-auditing already in place, a relational pivot table, and models that emit audit events. It does not replace your auditing strategy; it complements it. If Laravel Auditing is not already adopted, this package is not the entry point — adopt the parent package first, then layer this on for pivot coverage.
Migration path.
AuditablePivot/AuditableMorphPivot or wrap the relationship with auditableRelation() for the pilot set only.audits table with the expected auditable_type.Compatibility. Pin the package, Laravel, and Laravel Auditing versions explicitly. The v1.2.0 changelog is a compatibility contract you should test against: custom using() pivot classes must not be swapped, withPivot constraints must survive, and MorphToMany attach must be audited. Add regression tests for each of these before any Laravel minor upgrade. Verify the pivot's primary/unique keys work with HandlesAuditablePivot transactions.
Sequencing.
BelongsToMany and one MorphToMany; confirm audit rows, payload shape, and constraint preservation.sync() and toggle() paths.Maintenance. Single-maintainer, low-adoption package with a small but non-trivial internal surface (Eloquent pivot internals). Treat it as a dependency you may need to fork. Budget for an internal owner who can read Eloquent relationship internals and patch on Laravel upgrades. The added Pest suite and Boost guideline reduce onboarding cost but not the ownership burden.
Support. MIT, community-only, no SLA, 0 dependents means no crowd-sourced battle testing. Escalation is effectively "fix it ourselves." Acceptable only if the audit requirement (pivot-change traceability for compliance/forensics) is high enough to justify carrying that risk.
Scaling. Two extra SELECTs per relationship operation plus full related-model payloads in the audit table. sync() on large pivot sets scales linearly in both queries and audit rows. Plan for: audit table partitioning or archival, indexes on auditable_type/auditable_id/created_at, and possible async audit writes if the parent package supports queueing. High-churn pivots (frequent syncs) should be evaluated for exclusion or summarization.
Failure modes.
wherePivot()/query constraints dropped (fixed in v1.2.0) → wrong rows audited. Regression-test any constrained relationship.using() pivot producing TypeError or being replaced by AuditablePivot → runtime failure on relationship operations.HandlesAuditablePivot audits inside a transaction; failed outer transactions should roll back audit rows, but verify this matches your compliance expectation (some regimes expect attempts logged).sync() operations causing table growth and latency on the request path.Ramp-up. A competent Laravel team can understand usage in under a day; understanding why a given pivot is or isn't audited takes longer because it depends on Eloquent pivot internals and the wrapper semantics. Onboarding docs are thin (README + release notes), so plan for an internal runbook covering: which relationships are audited, the expected audit row shape, how to verify coverage, and the fork/patch procedure. The Boost guideline helps AI tooling but is not a substitute for a written internal standard.
How can I help you explore Laravel packages today?