Laravel EnsoLaravel Enso
Guide
Back End
Front End
GitHub
Guide
Back End
Front End
GitHub
  • Back End

    • Action Logger
    • Addresses
    • Algolia
    • Algolia Webshop
    • API
    • Audits
    • Avatars
    • Cache Chain
    • Calendar
    • Cargo Partner
    • Categories
    • Charts
    • CI/CD
    • Cli
    • CNP Validator
    • Comments
    • Commercial
    • Companies
    • Core
    • Countries
    • Currencies
    • Data Export
    • Data Import
    • Discounts
    • Documents
    • Dynamic Methods
    • EAV
    • Emag
    • Enums
    • Excel
    • Facebook
    • Files
    • Filters
    • Financials
    • Forms
    • Frisbo
    • Google
    • Helpers
    • Holidays
    • How-to
    • Image Transformer
    • Impersonate
    • Interactions
    • Inventory
    • IO
    • Localisation
    • Lockable Models
    • Logs
    • Measurement Units
    • Meili Search
    • Meili Search Webshop
    • Menus
    • Migrator
    • Monitored Emails
    • Notifications
    • Packaging Units
    • PDF
    • People
    • Permissions
    • Product Eav
    • Product Lots
    • Products
    • Questionnaires
    • Rememberable
    • Roles
    • Sale Channels
    • Searchable
    • Select
    • Sentry
    • Services
    • Smart Bill
    • Sms Advert
    • Stripe
    • Tables
    • Tasks
    • Teams
    • Ticketing
    • Track Who
    • Tutorials
    • Typesense
    • Typesense Webshop
    • Unit Conversion
    • Upgrade
    • UPS
    • User Groups
    • Users
    • Versions
    • Virtual Call Center
    • Vouchers
    • Webshop
    • Webshop Commercial

Action Logger

LicenseStableDownloadsPHPIssuesMerge Requests

Description

Action Logger records authenticated user activity for routes that opt into Enso's action-logger middleware.

It is a small backend package focused on request auditing at the application edge. It captures which authenticated user accessed which named route, by which HTTP method, at what URL, and how long the request took to complete.

The package is designed to work inside the Laravel Enso ecosystem and integrates with Enso users, permissions, and dynamic relationships.

Installation

This package comes pre-installed in Laravel Enso distributions that require activity tracking.

For standalone package installation inside an Enso-based application:

composer require laravel-enso/action-logger

The package auto-registers its service provider, loads its migrations, and registers the action-logger middleware alias.

Run the migrations after installation:

php artisan migrate

Features

  • Registers the action-logger route middleware alias.
  • Creates and maintains the action_logs table through package migrations.
  • Persists one log entry per authenticated request handled by the middleware.
  • Stores user_id, url, route, method, duration, and timestamps for each action.
  • Adds a dynamic actionLogs() relationship to the Enso User model.
  • Exposes an ActionLog model with user() and permission() relationships.
  • Links logged route names back to Enso permissions through the permission() relation.

Usage

Apply the middleware to the routes you want to track:

Route::middleware(['web', 'auth', 'action-logger'])
    ->group(function (): void {
        Route::get('/administration/users/{user}', UserController::class)
            ->name('administration.users.show');
    });

Once the middleware is active, every authenticated request matched by those routes will create a new action log entry when the request terminates.

The package also adds an actionLogs() relationship to the Enso user model, so user activity can be queried directly:

$logs = $user->actionLogs()
    ->latest()
    ->get();

API

Middleware

  • Alias: action-logger
  • Class: LaravelEnso\ActionLogger\Http\Middleware\ActionLogger
  • Behavior: creates the log entry in terminate(), after the response is sent

Model

LaravelEnso\ActionLogger\Models\ActionLog

Stored attributes:

  • user_id
  • url
  • route
  • method
  • duration
  • created_at
  • updated_at

Relationships:

  • user() Belongs to LaravelEnso\Users\Models\User
  • permission() Belongs to LaravelEnso\Permissions\Models\Permission using route -> name

Dynamic User Relation

The package binds an actionLogs() relation to LaravelEnso\Users\Models\User through the Enso dynamic-methods package.

Note

This package only logs actions for authenticated requests. If no authenticated user is available, no action log entry is created.

Because it relies on the resolved route name, routes without meaningful names provide less useful audit data.

Depends On

Required Enso packages:

  • laravel-enso/core ↗
  • laravel-enso/dynamic-methods ↗
  • laravel-enso/permissions ↗
  • laravel-enso/users ↗

Framework dependency:

  • Laravel 12 compatible application stack

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

Edit this page on GitHub
Last Updated: 4/19/2026, 10:21:16 PM
Next
Addresses