src/Entity/PrescriberSpeciality.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PrescriberSpecialityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassPrescriberSpecialityRepository::class)]
  8. class PrescriberSpeciality
  9. {
  10.     use IdentifiableTrait;
  11.     #[ORM\Column(length255)]
  12.     private ?string $name null;
  13.     #[ORM\Column(length255)]
  14.     private ?string $slug null;
  15.     #[ORM\ManyToMany(targetEntityPrescriber::class, mappedBy'specialities')]
  16.     private Collection $prescribers;
  17.     #[ORM\OneToMany(mappedBy'mainSpeciality'targetEntityPrescriber::class)]
  18.     private Collection $prescribersByMainSpeciality;
  19.     public function __construct()
  20.     {
  21.         $this->prescribers = new ArrayCollection();
  22.         $this->prescribersByMainSpeciality = new ArrayCollection();
  23.     }
  24.     public function __toString(): string
  25.     {
  26.      return $this->name;
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getName(): ?string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function setName(string $name): self
  37.     {
  38.         $this->name $name;
  39.         return $this;
  40.     }
  41.     public function getSlug(): ?string
  42.     {
  43.         return $this->slug;
  44.     }
  45.     public function setSlug(string $slug): self
  46.     {
  47.         $this->slug $slug;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection<int, Prescriber>
  52.      */
  53.     public function getPrescribers(): Collection
  54.     {
  55.         return $this->prescribers;
  56.     }
  57.     public function addPrescriber(Prescriber $prescriber): self
  58.     {
  59.         if (!$this->prescribers->contains($prescriber)) {
  60.             $this->prescribers->add($prescriber);
  61.             $prescriber->addSpeciality($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removePrescriber(Prescriber $prescriber): self
  66.     {
  67.         if ($this->prescribers->removeElement($prescriber)) {
  68.             $prescriber->removeSpeciality($this);
  69.         }
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Prescriber>
  74.      */
  75.     public function getPrescribersByMainSpeciality(): Collection
  76.     {
  77.         return $this->prescribersByMainSpeciality;
  78.     }
  79.     public function addPrescribersByMainSpeciality(Prescriber $prescribersByMainSpeciality): self
  80.     {
  81.         if (!$this->prescribersByMainSpeciality->contains($prescribersByMainSpeciality)) {
  82.             $this->prescribersByMainSpeciality->add($prescribersByMainSpeciality);
  83.             $prescribersByMainSpeciality->setMainSpeciality($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removePrescribersByMainSpeciality(Prescriber $prescribersByMainSpeciality): self
  88.     {
  89.         if ($this->prescribersByMainSpeciality->removeElement($prescribersByMainSpeciality)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($prescribersByMainSpeciality->getMainSpeciality() === $this) {
  92.                 $prescribersByMainSpeciality->setMainSpeciality(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97. }