31 lines
755 B
PHP
31 lines
755 B
PHP
|
|
<?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'),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|