Download the PHP package dvsoftsrl/laravel-attributechangelog without Composer
On this page you can find all versions of the php package dvsoftsrl/laravel-attributechangelog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dvsoftsrl/laravel-attributechangelog
More information about dvsoftsrl/laravel-attributechangelog
Files in dvsoftsrl/laravel-attributechangelog
Package laravel-attributechangelog
Short Description Attribute change logger for eloquent models
License MIT
Homepage https://github.com/dvsoftsrl/laravel-attributechangelog
Informations about the package laravel-attributechangelog
Attribute change logger for eloquent models
This package keeps track of every attribute that changes on an Eloquent model by storing one log row per attribute plus metadata about the acting model. It includes helpers to filter logs by attribute, subject, date, and causer so you can answer questions such as “when was status last changed on this model?” or “which models had stage updated yesterday?”
Features
- Automatically listen to the
created/updatedevents (customizable via$recordEvents) - Persist each mutated attribute as a separate log entry with its
subject,causer,attribute, and resolvedvalue - Support relation attributes and JSON-path segments (e.g.
order.customer.name,payload->meta.inner) - Expose fluent scopes for filtering by attribute, causer, date ranges, and subjects
Installation
You can install the package via composer:
You can publish and run the migrations with:
Note: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.
After publishing the migration you can create the activity_log table by running the migrations:
You can publish the config file with:
This is the contents of the published config file:
You can override the log model (must implement DvSoft\AttributeChangeLog\Contracts\AttributeChangeLog) or change the table/connection before running the migrations.
Usage
The trait listens for the configured events, writes one AttributeChangeLog row per attribute, and records the current value, root subject, optional JSON path, and optional causer. You can customize which attributes should be watched by overriding $attributesToBeLogged. When you record objects (for example, DTOs returned by custom casts) the log now keeps the original class plus a serialized payload so reading the entry returns the same object instance it stored.
Models that need to act as causers can use DvSoft\AttributeChangeLog\Traits\CausesActivity to expose the inverse morph relationship.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Luca Dell'Orto
- Stefano Vergani
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-attributechangelog with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0