2026-06-23 10:10:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Modules\History\DTOs;
|
|
|
|
|
|
|
|
|
|
use App\Modules\History\Requests\CreateHistoryEntryRequest;
|
|
|
|
|
use App\Modules\History\Requests\UpdateHistoryEntryRequest;
|
|
|
|
|
|
|
|
|
|
final class HistoryEntryData
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
2026-07-18 09:34:18 +00:00
|
|
|
public readonly ?int $historyEntryTypeId,
|
2026-06-23 10:10:28 +00:00
|
|
|
public readonly ?string $body,
|
2026-07-18 09:34:18 +00:00
|
|
|
public readonly ?string $occurredAt,
|
2026-06-23 10:10:28 +00:00
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
public static function fromCreateRequest(CreateHistoryEntryRequest $request): self
|
|
|
|
|
{
|
|
|
|
|
return new self(
|
2026-07-18 09:34:18 +00:00
|
|
|
historyEntryTypeId: (int) $request->validated('history_entry_type_id'),
|
2026-06-23 10:10:28 +00:00
|
|
|
body: $request->validated('body'),
|
2026-07-18 09:34:18 +00:00
|
|
|
occurredAt: $request->validated('occurred_at'),
|
2026-06-23 10:10:28 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function fromUpdateRequest(UpdateHistoryEntryRequest $request): self
|
|
|
|
|
{
|
|
|
|
|
return new self(
|
2026-07-18 09:34:18 +00:00
|
|
|
historyEntryTypeId: null,
|
2026-06-23 10:10:28 +00:00
|
|
|
body: $request->validated('body'),
|
2026-07-18 09:34:18 +00:00
|
|
|
occurredAt: $request->validated('occurred_at'),
|
2026-06-23 10:10:28 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|