Files
landing-api/app/Http/Resources/AuditLogResource.php
Josep Piguillem 1fe1e67773 Keep an audit log of who did what, and how they came in
Written from model events, spatie's role events and panel sign-ins, only for
what a person did, with secrets masked; pruned after a year.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 10:08:01 +02:00

38 lines
1009 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\AuditLog;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin AuditLog
*/
class AuditLogResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'action' => $this->action,
'user' => ['id' => $this->user_id, 'name' => $this->user_name],
'via' => $this->via,
'api_token_id' => $this->api_token_id,
'ip' => $this->ip,
'subject' => $this->subject_type ? [
'type' => $this->subject_type,
'id' => $this->subject_id,
'label' => $this->subject_label,
] : null,
'changes' => $this->changes === null ? null : (object) $this->changes,
'created_at' => $this->created_at?->toIso8601String(),
];
}
}