- Add isHidden field to Category entity with migration (DEFAULT false for existing rows) - Add isHidden checkbox to edit category template and "Masquee" badge on category list - Save isHidden in editCategory controller method - Fix Category.isActive() indentation - Create CategoryTest with full coverage (14 tests): defaults, setters, setEvent logic, isActive, isHidden - Add category CRUD tests to AccountControllerTest: add/edit/delete/reorder categories with access control - Add cookie-consent tests for dev env early return and Cloudflare tunnel script - Exclude PayoutPdfService from phpunit coverage and SonarQube analysis Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
139 lines
2.7 KiB
PHP
139 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\CategoryRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
|
|
class Category
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column]
|
|
private int $position = 0;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Event::class)]
|
|
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
|
private ?Event $event = null;
|
|
|
|
#[ORM\Column]
|
|
private \DateTimeImmutable $startAt;
|
|
|
|
#[ORM\Column]
|
|
private \DateTimeImmutable $endAt;
|
|
|
|
#[ORM\Column]
|
|
private bool $isHidden = false;
|
|
|
|
#[ORM\Column]
|
|
private \DateTimeImmutable $createdAt;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->createdAt = new \DateTimeImmutable();
|
|
$this->startAt = new \DateTimeImmutable();
|
|
$this->endAt = new \DateTimeImmutable('+30 days');
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(int $position): static
|
|
{
|
|
$this->position = $position;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEvent(): ?Event
|
|
{
|
|
return $this->event;
|
|
}
|
|
|
|
public function setEvent(?Event $event): static
|
|
{
|
|
$this->event = $event;
|
|
|
|
if ($event && $event->getStartAt()) {
|
|
$endCandidate = $event->getStartAt()->modify('-1 day');
|
|
$this->endAt = $endCandidate > $this->startAt ? $endCandidate : $event->getStartAt();
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStartAt(): \DateTimeImmutable
|
|
{
|
|
return $this->startAt;
|
|
}
|
|
|
|
public function setStartAt(\DateTimeImmutable $startAt): static
|
|
{
|
|
$this->startAt = $startAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEndAt(): \DateTimeImmutable
|
|
{
|
|
return $this->endAt;
|
|
}
|
|
|
|
public function setEndAt(\DateTimeImmutable $endAt): static
|
|
{
|
|
$this->endAt = $endAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isHidden(): bool
|
|
{
|
|
return $this->isHidden;
|
|
}
|
|
|
|
public function setIsHidden(bool $isHidden): static
|
|
{
|
|
$this->isHidden = $isHidden;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): \DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
$now = new \DateTimeImmutable();
|
|
|
|
return $now >= $this->startAt && $now <= $this->endAt;
|
|
}
|
|
}
|