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 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

At a glance

Frequently asked questions about Laravel Model Activity Log
How do I enable activity logging for an Eloquent model in Laravel?
Use the `LogsActivity` trait in your model class. The package automatically logs `created`, `updated`, `deleted`, and `restored` (if using SoftDeletes) events. No additional configuration is needed unless you customize log names or ignored/redacted attributes.
Does this package work with Laravel 12+ and PHP 8.3+?
Yes, the package explicitly requires Laravel 12+ and PHP 8.3+. If your project uses an older version, you’ll need to upgrade to use this package. Check the [repository](https://github.com/foxen-digital/laravel-model-activity-log) for potential backporting efforts.
Can I filter or query the activity logs beyond basic retrieval?
The package stores logs in a single `activity_log` table but does not expose a query builder. You’ll need to manually query the table or extend the package. For complex filtering (e.g., by user or time range), consider adding scopes or using Laravel’s query builder directly on the `activity_log` table.
How do I ignore specific attributes from being logged in updates?
Define a `protected $ignoreActivityLogAttributes` property in your model and list the attributes to exclude. For example, `$ignoreActivityLogAttributes = ['updated_at', 'password']` will skip these fields when logging updates or creates.
What happens if no authenticated user is present when logging an action?
Actions performed without an authenticated user (e.g., via CLI, queues, or API calls) are automatically attributed to the `System` causer. This ensures logs are never left unattributed, even in headless environments.
How do I redact sensitive data (e.g., passwords) in activity logs?
Use the `protected $redactedActivityLogAttributes` property in your model. The attribute keys will still appear in logs, but their values will be replaced with `[REDACTED]`. For example, `$redactedActivityLogAttributes = ['password', 'credit_card']` will mask these fields.
Is there a way to prune old activity logs automatically?
Yes, the package supports pruning old logs via Time-To-Live (TTL) policies. Configure retention rules in the `foxen_activitylog.php` config file, then schedule a Laravel command or cron job to run `php artisan activitylog:prune` periodically.
Will this package impact performance for high-frequency models?
Logging every update (including old/new attribute diffs) can introduce overhead, especially for models with frequent writes. Test performance under load, and consider disabling logging for non-critical models or batching log writes if needed.
Can I customize the log table name or schema?
The package uses a default `activity_log` table with a fixed schema. To customize the table name, override the `getActivityLogTable()` method in your model. Schema changes require manual migration adjustments, as the package does not support dynamic schema extensions.
What are the alternatives to this package, and how does it compare?
Alternatives include `laravel-audit` and `spatie/laravel-audit-logs`, which offer more query flexibility and sometimes additional features like real-time notifications. This package prioritizes simplicity and minimal setup, while alternatives may provide better scalability for complex auditing needs.
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.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium