mandant-crm/backend/app/Modules/History/DTOs/HistoryEntryData.php

31 lines
755 B
PHP
Raw Normal View History

<?php
namespace App\Modules\History\DTOs;
use App\Modules\History\Requests\CreateHistoryEntryRequest;
use App\Modules\History\Requests\UpdateHistoryEntryRequest;
final class HistoryEntryData
{
public function __construct(
public readonly ?string $type,
public readonly ?string $body,
) {}
public static function fromCreateRequest(CreateHistoryEntryRequest $request): self
{
return new self(
type: $request->validated('type'),
body: $request->validated('body'),
);
}
public static function fromUpdateRequest(UpdateHistoryEntryRequest $request): self
{
return new self(
type: null,
body: $request->validated('body'),
);
}
}