src/Entity/PrescriberCategory.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PrescriberCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\UX\Turbo\Attribute\Broadcast;
  8. #[ORM\Entity(repositoryClassPrescriberCategoryRepository::class)]
  9. #[Broadcast]
  10. class PrescriberCategory
  11. {
  12.     use IdentifiableTrait;
  13.     #[ORM\Column(length255)]
  14.     private ?string $name null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $slug null;
  17.     #[ORM\OneToMany(mappedBy'category'targetEntityPrescriber::class)]
  18.     private Collection $prescribers;
  19.     public function __construct()
  20.     {
  21.         $this->prescribers = new ArrayCollection();
  22.     }
  23.     function __toString(): string
  24.     {
  25.         return $this->name;
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getName(): ?string
  32.     {
  33.         return $this->name;
  34.     }
  35.     public function setName(string $name): self
  36.     {
  37.         $this->name $name;
  38.         return $this;
  39.     }
  40.     public function getSlug(): ?string
  41.     {
  42.         return $this->slug;
  43.     }
  44.     public function setSlug(string $slug): self
  45.     {
  46.         $this->slug $slug;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Prescriber>
  51.      */
  52.     public function getPrescribers(): Collection
  53.     {
  54.         return $this->prescribers;
  55.     }
  56.     public function addPrescriber(Prescriber $prescriber): self
  57.     {
  58.         if (!$this->prescribers->contains($prescriber)) {
  59.             $this->prescribers->add($prescriber);
  60.             $prescriber->setCategory($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removePrescriber(Prescriber $prescriber): self
  65.     {
  66.         if ($this->prescribers->removeElement($prescriber)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($prescriber->getCategory() === $this) {
  69.                 $prescriber->setCategory(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74. }