laravel-activity-loggerlisted
Install: claude install-skill Yaz-inc/yazinc-ai-toolkit
# Laravel Activity Logger (Hybrid)
Production audit log: **indexed columns** for filtering + **JSON column** for complete action context.
## When to use
- Any admin module needs who-did-what-when tracking
- Compliance or support requires searchable history by user, module, or entity
- You want one logger service called from all controllers
## Stack
- Laravel 10, Eloquent
- Table: `activity_logs`
- Service: static `ActivityLogger::log()` + optional entity helpers
## Database schema
```php
Schema::create('activity_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('action_type', 50); // create, update, delete, login, ...
$table->string('module', 50)->nullable();
$table->string('entity_type', 100)->nullable();
$table->unsignedBigInteger('entity_id')->nullable();
$table->string('entity_name')->nullable();
$table->json('action');
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
$table->index(['user_id', 'action_type', 'module', 'entity_type', 'entity_id', 'created_at']);
$table->index(['entity_type', 'entity_id']);
$table->index(['module', 'action_type']);
});
```
## Service pattern
```php
ActivityLogger::log(
'update', // action_type
'vendors', // module slug
'Vendor', //