src/Entity/Country.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CountryRepository;
  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(repositoryClassCountryRepository::class)]
  9. #[Broadcast]
  10. class Country
  11. {
  12.     use IdentifiableTrait;
  13.     #[ORM\Column(length255)]
  14.     private ?string $name null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $code null;
  17.     #[ORM\OneToMany(mappedBy'country'targetEntityCommercial::class)]
  18.     private Collection $commercials;
  19.     #[ORM\OneToMany(mappedBy'country'targetEntityPrescriber::class)]
  20.     private Collection $prescribers;
  21.     public function __construct()
  22.     {
  23.         $this->commercials = new ArrayCollection();
  24.         $this->prescribers = new ArrayCollection();
  25.     }
  26.     public function __toString(): string
  27.     {
  28.         return $this->name;
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getName(): ?string
  35.     {
  36.         return $this->name;
  37.     }
  38.     public function setName(string $name): self
  39.     {
  40.         $this->name $name;
  41.         return $this;
  42.     }
  43.     public function getCode(): ?string
  44.     {
  45.         return $this->code;
  46.     }
  47.     public function setCode(string $code): self
  48.     {
  49.         $this->code $code;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection<int, Commercial>
  54.      */
  55.     public function getCommercials(): Collection
  56.     {
  57.         return $this->commercials;
  58.     }
  59.     public function addCommercial(Commercial $commercial): self
  60.     {
  61.         if (!$this->commercials->contains($commercial)) {
  62.             $this->commercials->add($commercial);
  63.             $commercial->setCountry($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeCommercial(Commercial $commercial): self
  68.     {
  69.         if ($this->commercials->removeElement($commercial)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($commercial->getCountry() === $this) {
  72.                 $commercial->setCountry(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, Prescriber>
  79.      */
  80.     public function getPrescribers(): Collection
  81.     {
  82.         return $this->prescribers;
  83.     }
  84.     public function addPrescriber(Prescriber $prescriber): self
  85.     {
  86.         if (!$this->prescribers->contains($prescriber)) {
  87.             $this->prescribers->add($prescriber);
  88.             $prescriber->setCountry($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removePrescriber(Prescriber $prescriber): self
  93.     {
  94.         if ($this->prescribers->removeElement($prescriber)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($prescriber->getCountry() === $this) {
  97.                 $prescriber->setCountry(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102. }