src/Entity/Portfolio.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\PortfolioRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPortfolioRepository::class)]
  9. #[ApiResource]
  10. class Portfolio
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $portfolioName null;
  18.     #[ORM\ManyToOne(inversedBy'portfolios')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?ThirdParty $thirdParty null;
  21.     #[ORM\OneToMany(mappedBy'portfolio'targetEntityProduct::class, orphanRemovaltrue)]
  22.     private Collection $products;
  23.     public function __construct()
  24.     {
  25.         $this->products = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getPortfolioName(): ?string
  32.     {
  33.         return $this->portfolioName;
  34.     }
  35.     public function setPortfolioName(string $portfolioName): self
  36.     {
  37.         $this->portfolioName $portfolioName;
  38.         return $this;
  39.     }
  40.     public function getThirdParty(): ?ThirdParty
  41.     {
  42.         return $this->thirdParty;
  43.     }
  44.     public function setThirdParty(?ThirdParty $thirdParty): self
  45.     {
  46.         $this->thirdParty $thirdParty;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Product>
  51.      */
  52.     public function getProducts(): Collection
  53.     {
  54.         return $this->products;
  55.     }
  56.     public function addProduct(Product $product): self
  57.     {
  58.         if (!$this->products->contains($product)) {
  59.             $this->products->add($product);
  60.             $product->setPortfolio($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeProduct(Product $product): self
  65.     {
  66.         if ($this->products->removeElement($product)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($product->getPortfolio() === $this) {
  69.                 $product->setPortfolio(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74. }