TIDE/backend/app/Post/Post.php
yisroel 73a3acd39f
add Post entity, dto, repository interface
Post: id, userId (fk -> User), title, body, createdAt as
DateTimeImmutable. CreatePostDto readonly with explicit
createdAt (use case supplies it via Clock; entity remains pure).
PostRepository: create, find, findByUserId, findRecent (limit),
delete.
2026-05-06 15:19:00 +03:00

41 lines
682 B
PHP

<?php
namespace App\Post;
use DateTimeImmutable;
class Post
{
public function __construct(
private int $id,
private int $userId,
private string $title,
private string $body,
private DateTimeImmutable $createdAt,
) {}
public function getId(): int
{
return $this->id;
}
public function getUserId(): int
{
return $this->userId;
}
public function getTitle(): string
{
return $this->title;
}
public function getBody(): string
{
return $this->body;
}
public function getCreatedAt(): DateTimeImmutable
{
return $this->createdAt;
}
}