src/Entity/Country.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\CountryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCountryRepository::class)]
  9. #[ApiResource]
  10. class Country
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length4)]
  17.     private ?string $isoCode null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\OneToMany(mappedBy'country'targetEntityZone::class, orphanRemovaltrue)]
  21.     private Collection $zones;
  22.     #[ORM\OneToMany(mappedBy'country'targetEntityProvider::class, orphanRemovaltrue)]
  23.     private Collection $providers;
  24.     #[ORM\OneToMany(mappedBy'country'targetEntityThirdParty::class, orphanRemovaltrue)]
  25.     private Collection $thirdParties;
  26.     #[ORM\OneToMany(mappedBy'country'targetEntityInsured::class, orphanRemovaltrue)]
  27.     private Collection $insureds;
  28.     public function __construct()
  29.     {
  30.         $this->zones = new ArrayCollection();
  31.         $this->providers = new ArrayCollection();
  32.         $this->thirdParties = new ArrayCollection();
  33.         $this->insureds = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getIsoCode(): ?string
  40.     {
  41.         return $this->isoCode;
  42.     }
  43.     public function setIsoCode(string $isoCode): self
  44.     {
  45.         $this->isoCode $isoCode;
  46.         return $this;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, Zone>
  59.      */
  60.     public function getZones(): Collection
  61.     {
  62.         return $this->zones;
  63.     }
  64.     public function addZone(Zone $zone): self
  65.     {
  66.         if (!$this->zones->contains($zone)) {
  67.             $this->zones->add($zone);
  68.             $zone->setCountry($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeZone(Zone $zone): self
  73.     {
  74.         if ($this->zones->removeElement($zone)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($zone->getCountry() === $this) {
  77.                 $zone->setCountry(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Provider>
  84.      */
  85.     public function getProviders(): Collection
  86.     {
  87.         return $this->providers;
  88.     }
  89.     public function addProvider(Provider $provider): self
  90.     {
  91.         if (!$this->providers->contains($provider)) {
  92.             $this->providers->add($provider);
  93.             $provider->setCountry($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeProvider(Provider $provider): self
  98.     {
  99.         if ($this->providers->removeElement($provider)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($provider->getCountry() === $this) {
  102.                 $provider->setCountry(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, ThirdParty>
  109.      */
  110.     public function getThirdParties(): Collection
  111.     {
  112.         return $this->thirdParties;
  113.     }
  114.     public function addThirdParty(ThirdParty $thirdParty): self
  115.     {
  116.         if (!$this->thirdParties->contains($thirdParty)) {
  117.             $this->thirdParties->add($thirdParty);
  118.             $thirdParty->setCountry($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeThirdParty(ThirdParty $thirdParty): self
  123.     {
  124.         if ($this->thirdParties->removeElement($thirdParty)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($thirdParty->getCountry() === $this) {
  127.                 $thirdParty->setCountry(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, Insured>
  134.      */
  135.     public function getInsureds(): Collection
  136.     {
  137.         return $this->insureds;
  138.     }
  139.     public function addInsured(Insured $insured): self
  140.     {
  141.         if (!$this->insureds->contains($insured)) {
  142.             $this->insureds->add($insured);
  143.             $insured->setCountry($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeInsured(Insured $insured): self
  148.     {
  149.         if ($this->insureds->removeElement($insured)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($insured->getCountry() === $this) {
  152.                 $insured->setCountry(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157. }