monty7352 / quick-activity-log
A lightweight activity logger for Laravel Eloquent models.
v1.0.1
2026-09-30 17:15 UTC
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A lightweight and easy-to-use activity and audit logging package for Eloquent models in Laravel. Automatically tracks model creation, updates, and deletions without complex setup.
Features
- 🚀 Zero configuration needed to get started.
- 📦 Automatically tracks
created,updated, anddeletedevents on Eloquent models. - 💾 Stores attributes/changes as JSON in database.
- ⚡ Lightweight and fast execution.
Installation
You can install the package via Composer:
composer require your-github-username/quick-activity-log ## Usage Add the `LogsActivity` trait to any Eloquent model you want to track: ### Fetching Logs You can fetch logs using the `ActivityLog` model: Run the migrations to create the activity_logs table: Bash php artisan migrate Usage Add the LogsActivity trait to any Eloquent model you want to track: PHP namespace App\Models; use Illuminate\Database\Eloquent\Model; use YourGithubUsername\QuickActivityLog\Traits\LogsActivity; class User extends Model { use LogsActivity; protected $fillable = ['name', 'email', 'password']; } Fetching Logs You can fetch logs using the ActivityLog model: PHP use YourGithubUsername\QuickActivityLog\Models\ActivityLog; // Retrieve all activity logs ordered by newest first $logs = ActivityLog::latest()->get(); foreach ($logs as$log) { echo "Model: " . $log->subject_type . "\n"; // e.g., App\Models\User echo "Model ID: " . $log->subject_id . "\n"; // e.g., 1 echo "Action: " . $log->action . "\n"; // created, updated, or deleted // Output changed data array print_r($log->changes); }