2026-06-23 10:10:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Modules\History\Resources;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
|
|
class HistoryEntryResource extends JsonResource
|
|
|
|
|
{
|
|
|
|
|
public function toArray(Request $request): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'id' => $this->id,
|
|
|
|
|
'client_id' => $this->client_id,
|
2026-07-18 09:34:18 +00:00
|
|
|
'is_field_change' => $this->isFieldChange(),
|
|
|
|
|
'history_entry_type_id' => $this->history_entry_type_id,
|
|
|
|
|
// Field-change audit rows render under a fixed system label; user
|
|
|
|
|
// entries take their configured type name.
|
|
|
|
|
'type_name' => $this->isFieldChange() ? 'Stammdatenänderung' : $this->entryType?->name,
|
|
|
|
|
'requires_datetime' => $this->entryType?->requires_datetime ?? false,
|
|
|
|
|
// Naive local datetime (no Z/offset) so the user-typed HH:MM
|
|
|
|
|
// round-trips without timezone drift.
|
|
|
|
|
'occurred_at' => $this->occurred_at?->format('Y-m-d\TH:i:s'),
|
2026-06-23 10:10:28 +00:00
|
|
|
'body' => $this->body,
|
2026-07-18 09:34:18 +00:00
|
|
|
'custom_field_definition_id' => $this->custom_field_definition_id,
|
2026-06-23 10:10:28 +00:00
|
|
|
'author_id' => $this->author_id,
|
|
|
|
|
'author_name' => $this->author?->name,
|
|
|
|
|
'updated_by' => $this->updated_by,
|
|
|
|
|
'updated_by_name' => $this->updatedBy?->name,
|
|
|
|
|
'created_at' => $this->created_at->toISOString(),
|
|
|
|
|
'updated_at' => $this->updated_at->toISOString(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|