EthikTag/src/Entity/Patient.php

130 lines
2.7 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\PatientRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: PatientRepository::class)]
class Patient
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 100)]
#[Assert\Regex('/[A-Z][a-z]{0,99}/')]
private ?string $lastname = null;
#[ORM\Column(length: 100)]
private ?string $firstname = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $birthdate = null;
#[ORM\Column]
private ?string $donneurNumber = null;
#[ORM\OneToMany(mappedBy: 'donneur', targetEntity: Don::class, orphanRemoval: true)]
private Collection $dons;
public function __construct()
{
$this->dons = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getBirthdate(): ?\DateTimeInterface
{
return $this->birthdate;
}
public function setBirthdate(\DateTimeInterface $birthdate): self
{
$this->birthdate = $birthdate;
return $this;
}
public function getDonneurNumber(): ?string
{
return $this->donneurNumber;
}
public function setDonneurNumber(string $donneurNumber): self
{
$this->donneurNumber = $donneurNumber;
return $this;
}
/**
* @return Collection<int, Don>
*/
public function getDons(): Collection
{
return $this->dons;
}
public function addDon(Don $don): self
{
if (!$this->dons->contains($don)) {
$this->dons->add($don);
$don->setDonneur($this);
}
return $this;
}
public function removeDon(Don $don): self
{
if ($this->dons->removeElement($don)) {
// set the owning side to null (unless already changed)
if ($don->getDonneur() === $this) {
$don->setDonneur(null);
}
}
return $this;
}
public function __toString()
{
return $this->firstname.' '.$this->lastname;
}
}