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>
38 lines
1009 B
PHP
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(),
|
|
];
|
|
}
|
|
}
|