Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Model Activity Log Laravel Package

foxen/laravel-model-activity-log

Automatically log Eloquent model activity in Laravel: create, update (with attribute diffs), delete, and restore (SoftDeletes). Supports per-model log names, ignoring or redacting attributes, tracks the authenticated user or falls back to “System”, and can prune old entries.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Audit Trail Feature: Enables compliance with regulatory requirements (e.g., GDPR, HIPAA) by automatically tracking model changes without manual logging.
  • Debugging & Rollback: Provides a historical record of data modifications, simplifying troubleshooting and enabling point-in-time recovery.
  • User Activity Insights: Captures who made changes (via causer_id) to models, useful for accountability in collaborative environments (e.g., SaaS platforms, internal tools).
  • Roadmap Efficiency: Accelerates development by eliminating boilerplate logging code, allowing PMs to prioritize core features over infrastructure.
  • Build vs. Buy: Avoids reinventing the wheel for basic activity tracking, reducing technical debt while maintaining flexibility for customization (e.g., pruning policies, event extensions).
  • Use Cases:
    • Admin Dashboards: Power "Recent Activity" sections with minimal backend effort.
    • Data Governance: Automate retention policies (e.g., log deletions after 90 days).
    • Feature Flags: Log model changes tied to A/B tests or experimental features.

When to Consider This Package

  • Adopt When:

    • Your Laravel app requires automated, standardized audit logs for Eloquent models with minimal dev overhead.
    • You need soft-deletes + restoration tracking out of the box (supports SoftDeletes trait).
    • Your team lacks bandwidth to build a custom solution but needs configurable pruning (e.g., TTL-based cleanup).
    • You’re using Laravel 12+ and PHP 8.3+ (no legacy constraints).
    • The package’s MIT license aligns with your open-source policy.
  • Look Elsewhere If:

    • You need advanced querying (e.g., filtering logs by attribute changes) → Consider spatie/laravel-activitylog (more stars, richer features).
    • Your models use polymorphic relationships or require custom event logging → Extend this package or build bespoke.
    • You’re on Laravel <12 or PHP <8.3** → Not compatible.
    • Performance is critical for high-write workloads → Benchmark first (this package adds DB writes per event).
    • You need real-time notifications on model changes → Pair with Laravel Echo/Pusher or use a dedicated package.

How to Pitch It (Stakeholders)

For Executives: "This package lets us automatically track every change to critical data (e.g., user profiles, orders) without writing custom code—saving dev time while ensuring compliance with audit requirements. For example, if a support agent updates a customer record, we’ll log who made the change, what was altered, and when, all with zero manual effort. It’s like adding a ‘black box recorder’ to our database for a fraction of the cost of a custom build. The MIT license means no vendor lock-in, and the pruning feature keeps storage costs low."

For Engineering: *"This is a lightweight, trait-based solution to replace ad-hoc logging across models. Key benefits:

  • Zero setup per model: Just use LogsActivity to enable tracking for created, updated, deleted, and restored events.
  • Configurable: Publish the config to tweak pruning (e.g., delete logs older than 6 months) or extend events.
  • Integrates seamlessly: Works with Laravel’s event system and SoftDeletes out of the box.
  • Future-proof: Built for Laravel 12+, PHP 8.3+, and easy to fork if we need customizations. Tradeoff: Adds a single DB table and minor query overhead per event. For our scale, this is negligible compared to the dev time saved."*

For Developers: *"Imagine never writing Model::created() listeners again. This package:

  1. Automates CRUD logging for any model using the trait.
  2. Handles soft deletes (including restores) without extra code.
  3. Lets you prune old logs via config (e.g., prune_after_days: 90).
  4. Supports custom causer resolution (e.g., log the authenticated user or a service account). Example use case: Add it to User, Order, and Product models to instantly get a full audit trail. To customize, just extend the ActivityLog model or override the trait methods."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle