src/Entity/BC/VatProductGroup.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\BC;
  3. use App\Repository\BC\VatProductGroupRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassVatProductGroupRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. class VatProductGroup
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(type'string'length50)]
  13.     private string $id;
  14.     #[ORM\Column(type'string'length255nullabletrue)]
  15.     private ?string $productDesc null;
  16.     #[ORM\OneToMany(mappedBy'vatProductGroup',
  17.         targetEntityVatCombination::class,
  18.         cascade: ['persist''remove'],
  19.         orphanRemovaltrue
  20.     )]
  21.     private Collection $combinations;
  22.     #[ORM\Column(type'datetime_immutable')]
  23.     private \DateTimeImmutable $createdAt;
  24.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  25.     private ?\DateTimeImmutable $updatedAt null;
  26.     public function __construct(string $productCode)
  27.     {
  28.         $this->id $productCode;
  29.         $this->combinations = new ArrayCollection();
  30.     }
  31.     #[ORM\PrePersist]
  32.     public function onPrePersist(): void
  33.     {
  34.         $this->createdAt = new \DateTimeImmutable();
  35.     }
  36.     #[ORM\PreUpdate]
  37.     public function onPreUpdate(): void
  38.     {
  39.         $this->updatedAt = new \DateTimeImmutable();
  40.     }
  41.     public function getId(): string
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getProductDesc(): ?string
  46.     {
  47.         return $this->productDesc;
  48.     }
  49.     public function setProductDesc(?string $productDesc): void
  50.     {
  51.         $this->productDesc $productDesc;
  52.     }
  53.     public function getCombinations(): Collection
  54.     {
  55.         return $this->combinations;
  56.     }
  57.     public function addCombination(VatCombination $combination): void
  58.     {
  59.         if (!$this->combinations->contains($combination)) {
  60.             $this->combinations->add($combination);
  61.             $combination->setVatProductGroup($this);
  62.         }
  63.     }
  64.     public function removeCombination(VatCombination $combination): void
  65.     {
  66.         if ($this->combinations->removeElement($combination)) {
  67.             if ($combination->getVatProductGroup() === $this) {
  68.                 $combination->setVatProductGroup(null);
  69.             }
  70.         }
  71.     }
  72.     public function clearCombinations(): void
  73.     {
  74.         foreach ($this->combinations as $combination) {
  75.             $this->removeCombination($combination);
  76.         }
  77.     }
  78.     public function getCreatedAt(): \DateTimeImmutable
  79.     {
  80.         return $this->createdAt;
  81.     }
  82.     public function getUpdatedAt(): ?\DateTimeImmutable
  83.     {
  84.         return $this->updatedAt;
  85.     }
  86. }