Download the PHP package devdabour/laravel-loggable without Composer
On this page you can find all versions of the php package devdabour/laravel-loggable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devdabour/laravel-loggable
More information about devdabour/laravel-loggable
Files in devdabour/laravel-loggable
Package laravel-loggable
Short Description Enhanced activity logging for Laravel with metadata, relationships tracking, and size management
License MIT
Informations about the package laravel-loggable
Laravel Loggable
Enhanced activity logging for Laravel with metadata, relationships tracking, and size management.
Features
- 🚀 Easy to implement activity logging
- 📝 Customizable attribute mapping
- 🔍 Metadata tracking (IP, User Agent)
- 🔗 Relationship logging
- 📊 Content size management
- 🎯 Selective attribute logging
- 💾 Efficient storage handling
- 🌐 Translatable fields support
- 📄 JSON field handling
- 🧩 Nested JSON structure support
- ✨ Automatic translatable field processing (v1.0.5+)
- 🛡️ Support for Laravel 8.x, 9.x, and 10.x
Installation
You can install the package via composer:
The package will automatically register its service provider.
Configuration
Publish the configuration file:
This will create a loggable.php
configuration file in your config
directory.
Database Migration
After installing the package, you need to run the migration to create the activity log table:
This will create the necessary database table for storing activity logs.
Basic Usage
- Add the Loggable trait to your model:
Advanced Usage
Metadata Logging
Enable metadata logging to track IP address, user agent, and custom data:
Relationship Tracking
Track changes in related models:
Translatable Fields Support
If you're using Spatie's Translatable trait, Loggable will automatically handle translatable fields and log each language separately:
Note: Starting from version 1.0.5, translatable fields are processed automatically without requiring any custom methods.
Solution 1: Using the Nested Array Format (Recommended)
The most reliable way to ensure all languages are logged is to use the nested array format for your $logAttributes
:
This ensures that each language translation is logged separately, regardless of the current application locale.
Solution 2: Explicitly Define JSON Fields
You can also explicitly declare your translatable fields as JSON fields:
Solution 3: No Configuration Needed (v1.0.5+)
With version 1.0.5 and above, translatable fields are automatically processed without requiring any custom methods:
If you do need custom processing, you can still implement a modelCustomTapActivity
method which will be called after the automatic processing.
JSON Field Handling
Loggable now supports any JSON column, not just translatable fields:
Nested JSON Structures
For complex nested JSON data, Loggable automatically flattens the structure using dot notation:
You can provide custom labels for nested paths:
Utility Methods
The package provides several utility methods:
Changelog
1.0.5 (2025-07-18)
- Added automatic processing of translatable fields
- Fixed issues with modelCustomTapActivity method
- Improved handling of translatable fields across multiple languages
1.0.4 (2025-07-18)
- Made isJson method public for better utility access
- Fixed accessibility issues with helper methods
1.0.3 (2025-07-18)
- Added support for JSON field handling
- Added nested JSON structure support
- Enhanced mapping for complex data structures
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-loggable with dependencies
illuminate/support Version ^8.0|^9.0|^10.0
spatie/laravel-activitylog Version ^4.0