Adds nullable feature_slot column (unique) plus repo findByFeatureSlot/findFeatured/update methods so admins can pin a post into one of two slots.
52 lines
904 B
PHP
52 lines
904 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,
|
|
private ?int $featureSlot,
|
|
) {}
|
|
|
|
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;
|
|
}
|
|
|
|
public function getFeatureSlot(): ?int
|
|
{
|
|
return $this->featureSlot;
|
|
}
|
|
|
|
public function isFeatured(): bool
|
|
{
|
|
return $this->featureSlot !== null;
|
|
}
|
|
}
|