aw3r1se/laravel-audit-moonshine

MoonShine admin-panel bridge for aw3r1se/laravel-audit-core

Maintainers

Package info

github.com/aw3r1se/laravel-audit-moonshine

pkg:composer/aw3r1se/laravel-audit-moonshine

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-04 13:10 UTC

This package is auto-updated.

Last update: 2026-06-04 13:13:59 UTC


README

MoonShine admin-panel bridge for aw3r1se/laravel-audit-core. Reuses the same recording engine so actions performed through the MoonShine admin panel land in the same audit stream as your API.

Why a separate middleware

MoonShine fires many mutating requests that change nothing, and its env-based single-admin auth has no database user id. AuditMoonShineActions therefore:

  • dispatches only when the model layer actually recorded a change, and
  • stamps a configurable admin actor id (null by default) instead of the request user.

Everything else — what gets recorded, how it is delivered — is inherited from the core package and its transport.

Install

composer require aw3r1se/laravel-audit-moonshine

This bridge ships no config file of its own. Its single setting is merged at runtime into the core package's audit config under the moonshine key, so the only config you ever publish is config/audit.php from the core package.

Usage

Register the middleware in your MoonShine config so it wraps every admin request:

// config/moonshine.php
'middleware' => [
    // ...MoonShine defaults...
    \Aw3r1se\Audit\MoonShine\Http\Middleware\AuditMoonShineActions::class,
],

Make the MoonShine-managed models auditable exactly as in the core package (implements Auditable + use InteractsWithAudit).

Distinguish admin actions on the read side by their route name (moonshine.crud.*, moonshine.update-field.*), and substitute an admin display name for the null actor there.

Configuration

The actor id lives under the audit.moonshine namespace. Set it with the AUDIT_MOONSHINE_ACTOR_ID env var, or add a moonshine block to the published config/audit.php:

// config/audit.php
'moonshine' => [
    'actor_id' => env('AUDIT_MOONSHINE_ACTOR_ID'),
],
key default purpose
audit.moonshine.actor_id null user id stamped on actions made through the admin panel

Testing

composer install
composer test