LIVE DEMO — Laravel Package

Track every
user action with
one line of code

A drop-in Laravel activity logger. Add audit trails to any existing app in minutes — no config, no boilerplate, no headaches.

1
Line to log anything
9
Features included
Rows — indexed for scale
ActivityLogger.php
// Log any action — one line
use App\Helpers\ActivityLogger;
 
ActivityLogger::log(
  'FILE_UPLOAD',
  'Uploaded: invoice_2024.pdf'
);
 
// Auto-log via middleware
Route::middleware([
  'auth', 'log.activity'
])->group(...);
activity_logs — live feed LIVE
User authenticated successfully just now
UPLOAD Uploaded: invoice_2024.pdf 2s ago
UPDATE Request #42 → Completed 15s ago
What you get

Everything you need for full audit coverage

Production-tested in a live government voucher management system. Handles millions of rows without breaking a sweat.

One-Line Logging

ActivityLogger::log('ACTION', 'message') — works anywhere in your app. No setup, no service binding needed.

🔄

Auto-Log Middleware

Attach log.activity to any route group and every authenticated request is logged automatically.

🔍

Filter REST API

Query by action type, user ID, and date range out of the box. Includes an actionTypes() endpoint for dropdown population.

🗄️

Indexed for Scale

Migration includes indexes on action, user_id, and action_date. Fast at millions of rows.

🔗

User Relationship

Every log entry links to the user who triggered it. Load with ->with('user') for names in your UI.

🗑️

Soft Deletes

Logs are never permanently lost. Deleted entries stay in the database and can be restored for compliance audits.

📋

AuditTrails Model

A second model for tracking per-step process trails. Ideal for multi-step workflows with ordered states.

🎯

Specific User Logging

Log as any user — not just the authenticated one. Perfect for admin actions done on behalf of clients.

📦

Drop-in Ready

Copy src/ into your app, run php artisan migrate, and you're logging. No composer package, no config file.

Interactive demo

See exactly how it works

Click through the tabs to explore usage, query patterns, and the filter API.

Basic Usage
Middleware
Querying Logs
Filter API
use App\Helpers\ActivityLogger; // Log with the authenticated user (automatic) ActivityLogger::log('FILE_UPLOAD', 'Uploaded: invoice_2024.pdf'); ActivityLogger::log('USER_LOGIN', 'User logged in from 192.168.1.1'); ActivityLogger::log('STATUS_CHANGED', 'Request #42 → Completed'); // Log as a specific user ActivityLogger::log( 'ACCOUNT_CREATED', 'New client registered.', userId: $user->id );

RESULTING LOG ENTRIES

FILE_UPLOAD Uploaded: invoice_2024.pdf user_id: 5 · 2024-03-15 09:12:33
User logged in from 192.168.1.1 user_id: 5 · 2024-03-15 09:10:01
// Register in bootstrap/app.php (Laravel 11) $middleware->alias([ 'log.activity' => \App\Http\Middleware\LogActivity::class, ]); // Apply to any route group Route::middleware(['auth', 'log.activity:PAGE_VIEW']) ->group(function () { Route::get('/dashboard', DashboardController::class); Route::get('/reports', ReportController::class); });
use App\Models\ActivityLog; // Latest 50 logs with user info ActivityLog::with('user')->latest('action_date')->paginate(50); // Filter by action type ActivityLog::where('action', 'FILE_UPLOAD')->get(); // Filter by user ActivityLog::where('user_id', $userId)->get(); // Date range ActivityLog::whereDate('action_date', '>=', '2024-01-01')->get();
GET /audit-logs?action=FILE_UPLOAD&user_id=5&date_from=2024-01-01 Paginated filtered logs
GET /audit-logs/actions All distinct action types
GET /audit-logs/{id} Single log entry with user
File structure

Clean, organized source code

Copy src/ into your Laravel app/ directory. That's it.

src/
  Helpers/
    ActivityLogger.php  ← Static log() helper — use anywhere
  Models/
    ActivityLog.php  ← Eloquent model + user relationship + soft deletes
    AuditTrails.php  ← Per-step process trail model
  Http/
    Controllers/
      AuditLogController.php  ← index, show, actionTypes
    Middleware/
      LogActivity.php  ← Auto-log middleware
  database/migrations/
    create_activity_logs_table.php  ← Indexed for performance
README.md  ← Full installation guide
Requirements

Minimal dependencies

🐘

PHP 8.1+

Works with 8.1, 8.2, 8.3, 8.4

🔴

Laravel 10+

Compatible with Laravel 10 & 11

🗄️

MySQL 5.x+

Any MySQL-compatible database

📦

No extra packages

Pure Laravel — nothing extra to install

Get it now

Add audit trails to your Laravel app today

One-time purchase. Yours forever. Use in unlimited projects with Extended License.

$14/one-time

Buy on Codester →