src/Entity/Product.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ProductRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassProductRepository::class)]
  9. #[ApiResource]
  10. class Product
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $productName null;
  18.     #[ORM\Column]
  19.     private ?int $historyLength null;
  20.     #[ORM\ManyToOne(inversedBy'products')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?ProviderDatabase $productDatabase null;
  23.     #[ORM\ManyToOne(inversedBy'products')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?Variable $productVariable null;
  26.     #[ORM\ManyToOne(inversedBy'products')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     private ?Portfolio $portfolio null;
  29.     #[ORM\OneToMany(mappedBy'product'targetEntityCoverage::class, orphanRemovaltrue)]
  30.     private Collection $coverages;
  31.     #[ORM\OneToMany(mappedBy'product'targetEntityCatEvent::class, orphanRemovaltrue)]
  32.     private Collection $catEvents;
  33.     public function __construct()
  34.     {
  35.         $this->coverages = new ArrayCollection();
  36.         $this->catEvents = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getProductName(): ?string
  43.     {
  44.         return $this->productName;
  45.     }
  46.     public function setProductName(string $productName): self
  47.     {
  48.         $this->productName $productName;
  49.         return $this;
  50.     }
  51.     public function getHistoryLength(): ?int
  52.     {
  53.         return $this->historyLength;
  54.     }
  55.     public function setHistoryLength(int $historyLength): self
  56.     {
  57.         $this->historyLength $historyLength;
  58.         return $this;
  59.     }
  60.     public function getProductDatabase(): ?ProviderDatabase
  61.     {
  62.         return $this->productDatabase;
  63.     }
  64.     public function setProductDatabase(?ProviderDatabase $productDatabase): self
  65.     {
  66.         $this->productDatabase $productDatabase;
  67.         return $this;
  68.     }
  69.     public function getProductVariable(): ?Variable
  70.     {
  71.         return $this->productVariable;
  72.     }
  73.     public function setProductVariable(?Variable $productVariable): self
  74.     {
  75.         $this->productVariable $productVariable;
  76.         return $this;
  77.     }
  78.     public function getPortfolio(): ?Portfolio
  79.     {
  80.         return $this->portfolio;
  81.     }
  82.     public function setPortfolio(?Portfolio $portfolio): self
  83.     {
  84.         $this->portfolio $portfolio;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection<int, Coverage>
  89.      */
  90.     public function getCoverages(): Collection
  91.     {
  92.         return $this->coverages;
  93.     }
  94.     public function addCoverage(Coverage $coverage): self
  95.     {
  96.         if (!$this->coverages->contains($coverage)) {
  97.             $this->coverages->add($coverage);
  98.             $coverage->setProduct($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeCoverage(Coverage $coverage): self
  103.     {
  104.         if ($this->coverages->removeElement($coverage)) {
  105.             // set the owning side to null (unless already changed)
  106.             if ($coverage->getProduct() === $this) {
  107.                 $coverage->setProduct(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     /**
  113.      * @return Collection<int, CatEvent>
  114.      */
  115.     public function getCatEvents(): Collection
  116.     {
  117.         return $this->catEvents;
  118.     }
  119.     public function addCatEvent(CatEvent $catEvent): self
  120.     {
  121.         if (!$this->catEvents->contains($catEvent)) {
  122.             $this->catEvents->add($catEvent);
  123.             $catEvent->setProduct($this);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeCatEvent(CatEvent $catEvent): self
  128.     {
  129.         if ($this->catEvents->removeElement($catEvent)) {
  130.             // set the owning side to null (unless already changed)
  131.             if ($catEvent->getProduct() === $this) {
  132.                 $catEvent->setProduct(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137. }