src/Entity/Shop/Product/ProductAttribute.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Product;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Shop\Shop;
  5. use App\Repository\Shop\Product\ProductAttributeRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. #[ORM\Entity(repositoryClassProductAttributeRepository::class)]
  11. class ProductAttribute extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private ?string $id;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20. //    Like Size
  21.     #[ORM\ManyToOne(inversedBy'productAttributes')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Product $product null;
  24.     #[ORM\OneToMany(mappedBy'attribute'targetEntityProductAttributeValue::class)]
  25.     private Collection $productAttributeValues;
  26.     #[ORM\ManyToOne(inversedBy'productAttributes')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     private ?Shop $shop null;
  29.     public function __construct()
  30.     {
  31.         parent::__construct();
  32.         $this->productAttributeValues = new ArrayCollection();
  33.     }
  34.     public function getId(): ?string
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getProduct(): ?Product
  48.     {
  49.         return $this->product;
  50.     }
  51.     public function setProduct(?Product $product): static
  52.     {
  53.         $this->product $product;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, ProductAttributeValue>
  58.      */
  59.     public function getProductAttributeValues(): Collection
  60.     {
  61.         return $this->productAttributeValues;
  62.     }
  63.     public function addProductAttributeValue(ProductAttributeValue $productAttributeValue): static
  64.     {
  65.         if (!$this->productAttributeValues->contains($productAttributeValue)) {
  66.             $this->productAttributeValues->add($productAttributeValue);
  67.             $productAttributeValue->setAttribute($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeProductAttributeValue(ProductAttributeValue $productAttributeValue): static
  72.     {
  73.         $productAttributeValue->setActive(0);
  74.         return $this;
  75.         if ($this->productAttributeValues->removeElement($productAttributeValue)) {
  76.             // set the owning side to null (unless already changed)
  77.             if ($productAttributeValue->getAttribute() === $this) {
  78.                 $productAttributeValue->setAttribute(null);
  79.             }
  80.         }
  81.         return $this;
  82.     }
  83.     public function getShop(): ?Shop
  84.     {
  85.         return $this->shop;
  86.     }
  87.     public function setShop(?Shop $shop): static
  88.     {
  89.         $this->shop $shop;
  90.         return $this;
  91.     }
  92. }