calendi/backend/src/Domain/Model/Persisted/PersistedEvent.php
2025-04-26 05:43:35 +02:00

131 lines
2.7 KiB
PHP

<?php
namespace App\Domain\Model\Persisted;
use App\Infrastructure\Repository\EventRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: EventRepository::class)]
#[ORM\Table(name: 'app_event')]
class PersistedEvent
{
#[ORM\Id]
#[ORM\Column(type: 'string')]
private string $id;
#[ORM\Column(type: 'string', length: 255)]
#[Assert\NotBlank]
private string $title;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'event_from')]
#[Assert\NotNull]
private \DateTimeImmutable $from;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'event_to')]
#[Assert\NotNull]
#[Assert\GreaterThanOrEqual(propertyPath: 'from')]
private \DateTimeImmutable $to;
#[ORM\Column(type: 'boolean')]
private bool $allDay = false;
public function __construct()
{
$this->id = Uuid::v4()->toRfc4122();
}
public function getId(): string
{
return $this->id;
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getStart(): \DateTimeImmutable
{
return $this->from;
}
public function setStart(\DateTimeImmutable $start): self
{
$this->from = $start;
return $this;
}
public function getFrom(): \DateTimeImmutable
{
return $this->from;
}
public function setFrom(\DateTimeImmutable $from): self
{
$this->from = $from;
return $this;
}
public function getEnd(): \DateTimeImmutable
{
return $this->to;
}
public function setEnd(\DateTimeImmutable $end): self
{
$this->to = $end;
return $this;
}
public function getTo(): \DateTimeImmutable
{
return $this->to;
}
public function setTo(\DateTimeImmutable $to): self
{
$this->to = $to;
return $this;
}
public function isAllDay(): bool
{
return $this->allDay;
}
public function setAllDay(bool $allDay): self
{
$this->allDay = $allDay;
return $this;
}
}