src/Entity/StorageElement.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\StorageElementRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassStorageElementRepository::class)]
  11. #[ApiResource(
  12.     normalizationContext: ['groups' => ['storage_element:read']],
  13.     denormalizationContext: ['groups' => ['storage_element:write']],
  14.     order: ['id' => 'DESC']
  15. )]
  16. class StorageElement
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write''product:read''order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read'])]
  22.     private ?int $id null;
  23.     #[ORM\Column(length255)]
  24.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write','product:read'])]
  25.     private ?string $name null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write'])]
  28.     private ?\DateTimeInterface $dateEntered null;
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write'])]
  31.     private ?string $description null;
  32.     #[ORM\ManyToOne(inversedBy'storageElements')]
  33.     #[Groups(['storage_element:read''storage_element:write''product:read''order_product:read'])]
  34.     private ?Storage $storage null;
  35.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'storageElements')]
  36.     private ?self $parent null;
  37.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  38.     private Collection $storageElements;
  39.     #[ORM\Column(nullabletrue)]
  40.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write''product:read''order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read'])]
  41.     private ?bool $isMain null;
  42.     #[ORM\Column(length50nullabletrue)]
  43.     #[Groups(['storage:read''storage:write''storage_element:read''storage_element:write''product:read''order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read'])]
  44.     private ?string $c1Id null;
  45.     #[ORM\OneToMany(mappedBy'storageElement'targetEntityProducts::class)]
  46.     private Collection $products;
  47.     public function __construct()
  48.     {
  49.         $this->storageElements = new ArrayCollection();
  50.         $this->products = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getName(): ?string
  57.     {
  58.         return $this->name;
  59.     }
  60.     public function setName(string $name): self
  61.     {
  62.         $this->name $name;
  63.         return $this;
  64.     }
  65.     public function getDateEntered(): ?\DateTimeInterface
  66.     {
  67.         return $this->dateEntered;
  68.     }
  69.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  70.     {
  71.         $this->dateEntered $dateEntered;
  72.         return $this;
  73.     }
  74.     public function getDescription(): ?string
  75.     {
  76.         return $this->description;
  77.     }
  78.     public function setDescription(?string $description): self
  79.     {
  80.         $this->description $description;
  81.         return $this;
  82.     }
  83.     public function getStorage(): ?Storage
  84.     {
  85.         return $this->storage;
  86.     }
  87.     public function setStorage(?Storage $storage): self
  88.     {
  89.         $this->storage $storage;
  90.         return $this;
  91.     }
  92.     public function getParent(): ?self
  93.     {
  94.         return $this->parent;
  95.     }
  96.     public function setParent(?self $parent): self
  97.     {
  98.         $this->parent $parent;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return Collection<int, self>
  103.      */
  104.     public function getStorageElements(): Collection
  105.     {
  106.         return $this->storageElements;
  107.     }
  108.     public function addStorageElement(self $storageElement): self
  109.     {
  110.         if (!$this->storageElements->contains($storageElement)) {
  111.             $this->storageElements->add($storageElement);
  112.             $storageElement->setParent($this);
  113.         }
  114.         return $this;
  115.     }
  116.     public function removeStorageElement(self $storageElement): self
  117.     {
  118.         if ($this->storageElements->removeElement($storageElement)) {
  119.             // set the owning side to null (unless already changed)
  120.             if ($storageElement->getParent() === $this) {
  121.                 $storageElement->setParent(null);
  122.             }
  123.         }
  124.         return $this;
  125.     }
  126.     public function isIsMain(): ?bool
  127.     {
  128.         return $this->isMain;
  129.     }
  130.     public function setIsMain(?bool $isMain): self
  131.     {
  132.         $this->isMain $isMain;
  133.         return $this;
  134.     }
  135.     public function getC1Id(): ?string
  136.     {
  137.         return $this->c1Id;
  138.     }
  139.     public function setC1Id(?string $c1Id): self
  140.     {
  141.         $this->c1Id $c1Id;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection<int, Products>
  146.      */
  147.     public function getProducts(): Collection
  148.     {
  149.         return $this->products;
  150.     }
  151.     public function addProduct(Products $product): self
  152.     {
  153.         if (!$this->products->contains($product)) {
  154.             $this->products->add($product);
  155.             $product->setStorageElement($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeProduct(Products $product): self
  160.     {
  161.         if ($this->products->removeElement($product)) {
  162.             // set the owning side to null (unless already changed)
  163.             if ($product->getStorageElement() === $this) {
  164.                 $product->setStorageElement(null);
  165.             }
  166.         }
  167.         return $this;
  168.     }
  169. }