aw3r1se / laravel-audit-moonshine
MoonShine admin-panel bridge for aw3r1se/laravel-audit-core
Package info
github.com/aw3r1se/laravel-audit-moonshine
pkg:composer/aw3r1se/laravel-audit-moonshine
Requires
- php: ^8.3
- aw3r1se/laravel-audit-core: ^1.0
- illuminate/http: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0
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 (
nullby 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