src/Entity/Insured.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\InsuredRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassInsuredRepository::class)]
  10. #[ApiResource]
  11. class Insured
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $insuredName null;
  19.     #[ORM\ManyToOne(inversedBy'insureds')]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?Country $country null;
  22.     #[ORM\ManyToOne(inversedBy'insureds')]
  23.     #[ORM\JoinColumn(nullabletrue)]
  24.     private ?ThirdParty $thirdParty null;
  25.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  26.     private ?\DateTimeInterface $creationDate null;
  27.     #[ORM\OneToMany(mappedBy'insured'targetEntityCoverage::class, orphanRemovaltrue)]
  28.     private Collection $coverages;
  29.     public function __construct()
  30.     {
  31.         $this->coverages = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getInsuredName(): ?string
  38.     {
  39.         return $this->insuredName;
  40.     }
  41.     public function setInsuredName(string $insuredName): self
  42.     {
  43.         $this->insuredName $insuredName;
  44.         return $this;
  45.     }
  46.     public function getCountry(): ?Country
  47.     {
  48.         return $this->country;
  49.     }
  50.     public function setCountry(?Country $country): self
  51.     {
  52.         $this->country $country;
  53.         return $this;
  54.     }
  55.     public function getThirdParty(): ?ThirdParty
  56.     {
  57.         return $this->thirdParty;
  58.     }
  59.     public function setThirdParty(?ThirdParty $thirdParty): self
  60.     {
  61.         $this->thirdParty $thirdParty;
  62.         return $this;
  63.     }
  64.     public function getCreationDate(): ?\DateTimeInterface
  65.     {
  66.         return $this->creationDate;
  67.     }
  68.     public function setCreationDate(\DateTimeInterface $creationDate): self
  69.     {
  70.         $this->creationDate $creationDate;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, Coverage>
  75.      */
  76.     public function getCoverages(): Collection
  77.     {
  78.         return $this->coverages;
  79.     }
  80.     public function addCoverage(Coverage $coverage): self
  81.     {
  82.         if (!$this->coverages->contains($coverage)) {
  83.             $this->coverages->add($coverage);
  84.             $coverage->setInsured($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeCoverage(Coverage $coverage): self
  89.     {
  90.         if ($this->coverages->removeElement($coverage)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($coverage->getInsured() === $this) {
  93.                 $coverage->setInsured(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98. }