<?php
namespace App\Entity;
use App\Repository\SymptomRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: SymptomRepository::class), ORM\Table(name: 'symptoms')]
class Symptom implements \Stringable
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: DiseaseCategory::class, inversedBy: 'symptoms')]
#[ORM\JoinColumn(name: 'category_id', nullable: false), Assert\NotBlank]
private $diseaseCategory;
#[ORM\Column(type: 'string', length: 255), Assert\NotBlank]
#[Assert\Length(
min: 2,
max: 20,
minMessage: 'Symptom name must be at least {{ limit }} characters long',
maxMessage: 'Symptom name cannot be longer than {{ limit }} characters'
)]
#[Assert\Regex(
pattern: '/\d/',
match: false,
message: 'Symptom name cannot contain a number'
)]
private $name;
#[ORM\Column(type: 'boolean')]
private bool $isActive = true;
#[Gedmo\Timestampable(on: 'create'), ORM\Column(type: 'datetime')]
private $createdAt;
#[Gedmo\Timestampable(on: 'update'), ORM\Column(type: 'datetime')]
private $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getDiseaseCategory(): ?DiseaseCategory
{
return $this->diseaseCategory;
}
public function setDiseaseCategory(?DiseaseCategory $diseaseCategory): self
{
$this->diseaseCategory = $diseaseCategory;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function __toString(): string
{
return $this->getName();
}
}