PHPackages                             enadstack/laravel-action-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. enadstack/laravel-action-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

enadstack/laravel-action-logger
===============================

A powerful, flexible Action Logger / Audit Log package for Laravel with multi-tenancy support and optional Vue UI

1.0.0(6mo ago)01MITPHPPHP ^8.2CI passing

Since Dec 24Pushed 6mo agoCompare

[ Source](https://github.com/Enadabuzaid/laravel-action-logger)[ Packagist](https://packagist.org/packages/enadstack/laravel-action-logger)[ Docs](https://github.com/enadstack/laravel-action-logger)[ RSS](/packages/enadstack-laravel-action-logger/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (7)Versions (2)Used By (0)

 [![Laravel Action Logger](https://raw.githubusercontent.com/enadstack/laravel-action-logger/main/art/logo.svg)](https://raw.githubusercontent.com/enadstack/laravel-action-logger/main/art/logo.svg)

 [![Latest Version](https://camo.githubusercontent.com/73e553eabf18ffe81be9665ac7c4f6905e5aae1d57c870d9db676a368050e351/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656e6164737461636b2f6c61726176656c2d616374696f6e2d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/enadstack/laravel-action-logger) [![Total Downloads](https://camo.githubusercontent.com/4dbe7cd3dba00a0d46d21572cf5593cb58968c68f424e916dc9bb76870767118/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e6164737461636b2f6c61726176656c2d616374696f6e2d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/enadstack/laravel-action-logger) [![Tests](https://camo.githubusercontent.com/ba90d4f48af3e55a2463c1e76ad6ac07382f073e6e91f31cab83958763195fa5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656e6164737461636b2f6c61726176656c2d616374696f6e2d6c6f676765722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/enadstack/laravel-action-logger/actions) [![License](https://camo.githubusercontent.com/b6b99a346a3fb72996984b6f63c2de1033231ed9e2dbc88c7a29c234b5bdbb05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656e6164737461636b2f6c61726176656c2d616374696f6e2d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://github.com/enadstack/laravel-action-logger/blob/main/LICENSE)

Laravel Action Logger
=====================

[](#laravel-action-logger)

A powerful, flexible, and developer-friendly Action Logger / Audit Log package for Laravel. Track all changes to your Eloquent models, support multi-tenancy out of the box, and optionally visualize logs with a beautiful Inertia + Vue 3 UI.

✨ Features
----------

[](#-features)

FeatureDescription🔍 **Automatic CRUD Logging**Log `created`, `updated`, `deleted`, `restored` events automatically📝 **Smart Diff Tracking**Only logs changed attributes on updates🏢 **Multi-Tenant Ready**Column-based, request-based, or custom resolver🎯 **Fluent API**Both direct method and fluent builder patterns🔎 **Rich Query Scopes**Filter by subject, actor, event, date, tenant, and more🎨 **Optional UI**Beautiful Inertia + Vue 3 + shadcn-vue dashboard🔧 **Highly Configurable**Ignore attributes, models, events, and more⚡ **Laravel 11 &amp; 12**Full compatibility with latest Laravel versions🧪 **Fully Tested**55+ automated tests📋 Requirements
--------------

[](#-requirements)

RequirementVersionPHP8.2 or higherLaravel11.0 or 12.0🚀 Installation
--------------

[](#-installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require enadstack/laravel-action-logger
```

### Step 2: Run the Install Command

[](#step-2-run-the-install-command)

```
php artisan action-logger:install
```

This will:

- ✅ Publish the configuration file
- ✅ Publish the migration
- ✅ Optionally run the migration
- ✅ Display next steps

### Alternative: Manual Installation

[](#alternative-manual-installation)

```
# Publish config
php artisan vendor:publish --tag=action-logger-config

# Publish migration
php artisan vendor:publish --tag=action-logger-migrations

# Run migration
php artisan migrate
```

📖 Quick Start
-------------

[](#-quick-start)

### 1. Add the Trait to Your Models

[](#1-add-the-trait-to-your-models)

```
use Enadstack\ActionLogger\Traits\HasActionLogs;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasActionLogs;
}
```

That's it! Now all CRUD operations are automatically logged:

```
// Logged: created
$post = Post::create(['title' => 'My First Post']);

// Logged: updated (only changed fields)
$post->update(['title' => 'Updated Title']);

// Logged: deleted
$post->delete();
```

### 2. Query the Logs

[](#2-query-the-logs)

```
// Get all logs for a model
$logs = $post->actionLogs;

// Get the latest log
$latestLog = $post->latestActionLog();

// Get changes from an update
if ($latestLog->isUpdated()) {
    foreach ($latestLog->getChanges() as $field => $change) {
        echo "{$field}: {$change['old']} → {$change['new']}";
    }
}
```

### 3. Log Custom Events

[](#3-log-custom-events)

```
// Simple custom event
$post->logAction('published');

// With metadata
$post->logAction('shared', meta: [
    'platform' => 'twitter',
    'url' => 'https://...',
]);
```

📚 Documentation
---------------

[](#-documentation)

DocumentDescription📘 [Usage Guide](docs/USAGE.md)ActionLogger service and facade usage📗 [Trait Documentation](docs/TRAIT.md)HasActionLogs trait complete guide📖 [API Reference](docs/API.md)Complete API documentation🔧 [Commands](docs/COMMANDS.md)Artisan commands reference🎨 [UI Guide](docs/UI.md)Optional Inertia + Vue UI setup📋 [Quick Reference](docs/QUICK-REFERENCE.md)Cheat sheet for common tasks🏢 [Multi-Tenancy](docs/MULTI-TENANCY.md)Multi-tenant configuration guide⚙️ [Configuration](docs/CONFIGURATION.md)Complete configuration reference🔄 [Changelog](CHANGELOG.md)Version history🔧 Configuration
---------------

[](#-configuration)

After installation, you can customize behavior in `config/action-logger.php`:

### Enable/Disable Logging

[](#enabledisable-logging)

```
// config/action-logger.php
'enabled' => env('ACTION_LOGGER_ENABLED', true),
```

### Configure Events

[](#configure-events)

```
'events' => [
    'created',
    'updated',
    'deleted',
    'restored',
],
```

### Ignore Attributes

[](#ignore-attributes)

```
'ignore_attributes' => [
    'updated_at',
    'remember_token',
    'password',
],
```

### Multi-Tenancy

[](#multi-tenancy)

```
'tenant' => [
    'mode' => 'column', // 'none', 'column', or 'resolver'
    'column' => 'tenant_id',
],
```

🏢 Multi-Tenancy Support
-----------------------

[](#-multi-tenancy-support)

The package supports three tenancy modes:

### 1. No Tenancy (Default)

[](#1-no-tenancy-default)

```
'tenant' => [
    'mode' => 'none',
],
```

### 2. Column-Based Tenancy

[](#2-column-based-tenancy)

Automatically reads tenant ID from your models:

```
'tenant' => [
    'mode' => 'column',
    'column' => 'tenant_id', // or 'provider_id', 'organization_id', etc.
],
```

### 3. Custom Resolver

[](#3-custom-resolver)

Use your own logic to determine tenant context:

```
'tenant' => [
    'mode' => 'resolver',
    'resolver' => \App\Services\MyTenantResolver::class,
],
```

See [Multi-Tenancy Guide](docs/MULTI-TENANCY.md) for complete documentation.

🎨 Optional UI
-------------

[](#-optional-ui)

The package includes a beautiful Inertia + Vue 3 + shadcn-vue UI for viewing logs.

### Enable the UI

[](#enable-the-ui)

```
# In .env
ACTION_LOGGER_UI_ENABLED=true
```

### Publish UI Components (Optional)

[](#publish-ui-components-optional)

```
php artisan vendor:publish --tag=action-logger-ui
```

### Access the Dashboard

[](#access-the-dashboard)

Visit `/action-logs` to see:

- 📊 **Dashboard** - Statistics and recent activity
- 📋 **All Logs** - Filterable, paginated log viewer
- 📦 **Module Logs** - Logs grouped by model type
- 🔍 **Record Timeline** - Complete history for any record

See [UI Guide](docs/UI.md) for full documentation.

🔎 Advanced Usage
----------------

[](#-advanced-usage)

### Fluent API

[](#fluent-api)

```
use Enadstack\ActionLogger\Facades\ActionLogger;

ActionLogger::for($post)
    ->by($user)
    ->event('featured')
    ->withOld(['featured' => false])
    ->withNew(['featured' => true])
    ->addMeta('reason', 'Editor choice')
    ->save();
```

### Custom Actor Resolution

[](#custom-actor-resolution)

```
class Order extends Model
{
    use HasActionLogs;

    protected function getActionLogActor(): ?object
    {
        return User::find($this->processed_by) ?? auth()->user();
    }
}
```

### Conditional Logging

[](#conditional-logging)

```
class Comment extends Model
{
    use HasActionLogs;

    protected function shouldLogActionEvent(string $event): bool
    {
        return !$this->is_spam;
    }
}
```

### Rich Querying

[](#rich-querying)

```
use Enadstack\ActionLogger\Models\ActionLog;

// Combine multiple scopes
$logs = ActionLog::forSubject($post)
    ->forEvents(['created', 'updated'])
    ->recent(30)
    ->userActions()
    ->with('actor')
    ->latest()
    ->paginate(20);

// Track price changes
$priceHistory = $product->actionLogs()
    ->forEvent('updated')
    ->get()
    ->filter(fn($log) => $log->hasChangeFor('price'));
```

🔨 Maintenance
-------------

[](#-maintenance)

### Prune Old Logs

[](#prune-old-logs)

```
# Remove logs older than 90 days
php artisan action-logger:prune --days=90

# Preview (dry run)
php artisan action-logger:prune --days=60 --dry-run

# Prune for specific tenant
php artisan action-logger:prune --tenant=1 --days=90
```

### View Statistics

[](#view-statistics)

```
# Stats for last 30 days
php artisan action-logger:stats

# Stats for last 7 days
php artisan action-logger:stats --days=7
```

### Schedule Automatic Pruning

[](#schedule-automatic-pruning)

```
// app/Console/Kernel.php
protected function schedule(Schedule $schedule): void
{
    $schedule->command('action-logger:prune --days=90')
        ->weekly()
        ->sundays()
        ->at('02:00');
}
```

🧪 Testing
---------

[](#-testing)

The package includes a comprehensive test suite:

```
# Run all tests
composer test

# Run with PHPUnit directly
vendor/bin/phpunit

# Run specific test suite
vendor/bin/phpunit --testsuite=Unit
vendor/bin/phpunit --testsuite=Feature

# Generate coverage report
vendor/bin/phpunit --coverage-html coverage
```

💡 Examples
----------

[](#-examples)

Check out the example files in `src/Examples/`:

- `ExampleUsage.php` - Service and facade usage examples
- `ExampleHasActionLogs.php` - Trait usage and customization
- `ExampleCustomTenantResolver.php` - Custom tenant resolver implementation

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

🙏 Credits
---------

[](#-credits)

- [Enad Abu Zaid](https://github.com/enadabuzaid)
- [All Contributors](../../contributors)

---

Made with ❤️ by [EnadStack](https://enadstack.com)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance67

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

191d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49005097?v=4)[Enad Abuzaid](/maintainers/Enadabuzaid)[@Enadabuzaid](https://github.com/Enadabuzaid)

---

Top Contributors

[![Enadabuzaid](https://avatars.githubusercontent.com/u/49005097?v=4)](https://github.com/Enadabuzaid "Enadabuzaid (1 commits)")

---

Tags

laravelloggingtrackingAudithistorymulti-tenantactivity-logaudit-logaction-loggerenadstack

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/enadstack-laravel-action-logger/health.svg)

```
[![Health](https://phpackages.com/badges/enadstack-laravel-action-logger/health.svg)](https://phpackages.com/packages/enadstack-laravel-action-logger)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.4k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58170.8k14](/packages/api-platform-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
