src/Flexy/ShopBundle/Entity/Product/ProductPack.php line 11

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Product;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Flexy\ShopBundle\Entity\Product\ProductPackRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassProductPackRepository::class)]
  7. #[ApiResource]
  8. class ProductPack
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\ManyToOne]
  15.     private ?Product $product null;
  16.     #[ORM\Column(nullabletrue)]
  17.     private ?int $quantity null;
  18.     #[ORM\ManyToOne(inversedBy'childrenPackProducts')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Product $parentProduct null;
  21.     public function __toString()
  22.     {
  23.         return $this->product." x ".$this->quantity;
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getProduct(): ?Product
  30.     {
  31.         return $this->product;
  32.     }
  33.     public function setProduct(?Product $product): self
  34.     {
  35.         $this->product $product;
  36.         return $this;
  37.     }
  38.     public function getQuantity(): ?int
  39.     {
  40.         return $this->quantity;
  41.     }
  42.     public function setQuantity(?int $quantity): self
  43.     {
  44.         $this->quantity $quantity;
  45.         return $this;
  46.     }
  47.     public function getParentProduct(): ?Product
  48.     {
  49.         return $this->parentProduct;
  50.     }
  51.     public function setParentProduct(?Product $parentProduct): self
  52.     {
  53.         $this->parentProduct $parentProduct;
  54.         return $this;
  55.     }
  56. }