src/Entity/Specialty.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SpecialtyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSpecialtyRepository::class)]
  9. class Specialty
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  18.     private ?string $description null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $code null;
  21.     #[ORM\Column]
  22.     private ?\DateTimeImmutable $createdAt null;
  23.     #[ORM\ManyToMany(targetEntityDoctor::class, mappedBy'specialties')]
  24.     private Collection $doctors;
  25.     public function __construct()
  26.     {
  27.         $this->doctors = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): static
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     public function getDescription(): ?string
  43.     {
  44.         return $this->description;
  45.     }
  46.     public function setDescription(?string $description): static
  47.     {
  48.         $this->description $description;
  49.         return $this;
  50.     }
  51.     public function getCode(): ?string
  52.     {
  53.         return $this->code;
  54.     }
  55.     public function setCode(?string $code): static
  56.     {
  57.         $this->code $code;
  58.         return $this;
  59.     }
  60.     public function getCreatedAt(): ?\DateTimeImmutable
  61.     {
  62.         return $this->createdAt;
  63.     }
  64.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  65.     {
  66.         $this->createdAt $createdAt;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, Doctor>
  71.      */
  72.     public function getDoctors(): Collection
  73.     {
  74.         return $this->doctors;
  75.     }
  76.     public function addDoctor(Doctor $doctor): static
  77.     {
  78.         if (!$this->doctors->contains($doctor)) {
  79.             $this->doctors->add($doctor);
  80.             $doctor->addSpecialty($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeDoctor(Doctor $doctor): static
  85.     {
  86.         if ($this->doctors->removeElement($doctor)) {
  87.             $doctor->removeSpecialty($this);
  88.         }
  89.         return $this;
  90.     }
  91. }