start
This commit is contained in:
126
src/Entity/Patient.php
Normal file
126
src/Entity/Patient.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PatientRepository::class)]
|
||||
class Patient
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
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 ?int $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(): ?int
|
||||
{
|
||||
return $this->donneurNumber;
|
||||
}
|
||||
|
||||
public function setDonneurNumber(int $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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user