src/Entity/Storage.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\StorageRepository;
  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 ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassStorageRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['storage:read']],
  15.     denormalizationContext: ['groups' => ['storage:write']],
  16.     order: ['id' => 'DESC']
  17. )]
  18. #[ApiFilter(SearchFilter::class, properties: ['code1c' => 'exact''name' => 'ipartial'])]
  19. #[ORM\HasLifecycleCallbacks]
  20. class Storage 
  21. {
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     #[Groups(['storage:read''storage:write''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invocie:read''storage_element:read''product:read''order_product:read''product_storage_balance:read'])]
  26.     private ?int $id null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     #[Groups(['storage:read''storage:write''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invocie:read''storage_element:read''product:read''order_product:read''product_storage_balance:read'])]
  29.     private ?string $name null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  31.     private ?\DateTimeInterface $date_entered null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     private ?\DateTimeInterface $date_modified null;
  34.     #[ORM\ManyToOne]
  35.     private ?User $created_by null;
  36.     #[ORM\ManyToOne]
  37.     private ?User $modified_user null;
  38.     #[ORM\Column(length100nullabletrue)]
  39.     #[Groups(['storage:read''storage:write'])]
  40.     private ?string $status null;
  41.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  42.     #[Groups(['storage:read''storage:write'])]
  43.     private ?string $description null;
  44.     #[ORM\Column(length20nullabletrue)]
  45.     #[Groups(['storage:read''storage:write'])]
  46.     private ?string $stock_id null;
  47.     #[ORM\ManyToOne(targetEntityself::class)]
  48.     #[Groups(['storage:read''storage:write'])]
  49.     private ?self $parent null;
  50.     #[ORM\Column(length20nullabletrue)]
  51.     #[Groups(['storage:read''storage:write''storage_element:read''product:read''order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''product_storage_balance:read'])]
  52.     private ?string $c1id null;
  53.     #[ORM\OneToMany(mappedBy'storage'targetEntityIncomingInvoice::class)]
  54.     private Collection $incomingInvoices;
  55.     #[ORM\OneToMany(mappedBy'storage'targetEntityIncomingInvoiceProduct::class)]
  56.     private Collection $incomingInvoiceProducts;
  57.     #[ORM\OneToMany(mappedBy'storage'targetEntityOrders::class)]
  58.     private Collection $orders;
  59.     #[ORM\Column(length20nullabletrue)]
  60.     #[Groups(['storage:read''storage:write''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invocie:read''product_storage_balance:read''product:read'])]
  61.     private ?string $code1c null;
  62.     #[ORM\OneToMany(mappedBy'storage'targetEntityProducts::class)]
  63.     private Collection $products;
  64.     #[Groups(['storage:read''storage:write'])]
  65.     #[ORM\OneToMany(mappedBy'storage'targetEntityStorageElement::class)]
  66.     private Collection $storageElements;
  67.     #[ORM\OneToMany(mappedBy'storage'targetEntityProductBalanceInStorage::class)]
  68.     private Collection $productBalanceInStorages;
  69.     #[Groups(['storage:read''storage:write'])]
  70.     #[ORM\ManyToMany(targetEntityLocation::class, inversedBy'storages'cascade:['persist''remove'])]
  71.     private Collection $location;
  72.     #[ORM\OneToMany(mappedBy'storage'targetEntityOrderProduct::class)]
  73.     private Collection $orderProducts;
  74.     public function __construct()
  75.     {
  76.         $this->incomingInvoices = new ArrayCollection();
  77.         $this->incomingInvoiceProducts = new ArrayCollection();
  78.         $this->orders = new ArrayCollection();
  79.         $this->products = new ArrayCollection();
  80.         $this->storageElements = new ArrayCollection();
  81.         $this->productBalanceInStorages = new ArrayCollection();
  82.         $this->location = new ArrayCollection();
  83.         $this->orderProducts = new ArrayCollection();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getName(): ?string
  90.     {
  91.         return $this->name;
  92.     }
  93.     public function setName(?string $name): self
  94.     {
  95.         $this->name $name;
  96.         return $this;
  97.     }
  98.     public function getDateEntered(): ?\DateTimeInterface
  99.     {
  100.         return $this->date_entered;
  101.     }
  102.     public function setDateEntered(?\DateTimeInterface $date_entered): self
  103.     {
  104.         $this->date_entered $date_entered;
  105.         return $this;
  106.     }
  107.     public function getDateModified(): ?\DateTimeInterface
  108.     {
  109.         return $this->date_modified;
  110.     }
  111.     public function setDateModified(?\DateTimeInterface $date_modified): self
  112.     {
  113.         $this->date_modified $date_modified;
  114.         return $this;
  115.     }
  116.     public function getCreatedBy(): ?User
  117.     {
  118.         return $this->created_by;
  119.     }
  120.     public function setCreatedBy(?User $created_by): self
  121.     {
  122.         $this->created_by $created_by;
  123.         return $this;
  124.     }
  125.     public function getModifiedUser(): ?User
  126.     {
  127.         return $this->modified_user;
  128.     }
  129.     public function setModifiedUser(?User $modified_user): self
  130.     {
  131.         $this->modified_user $modified_user;
  132.         return $this;
  133.     }
  134.     public function getStatus(): ?string
  135.     {
  136.         return $this->status;
  137.     }
  138.     public function setStatus(?string $status): self
  139.     {
  140.         $this->status $status;
  141.         return $this;
  142.     }
  143.     public function getDescription(): ?string
  144.     {
  145.         return $this->description;
  146.     }
  147.     public function setDescription(?string $description): self
  148.     {
  149.         $this->description $description;
  150.         return $this;
  151.     }
  152.     public function getStockId(): ?string
  153.     {
  154.         return $this->stock_id;
  155.     }
  156.     public function setStockId(?string $stock_id): self
  157.     {
  158.         $this->stock_id $stock_id;
  159.         return $this;
  160.     }
  161.     public function getParent(): ?self
  162.     {
  163.         return $this->parent;
  164.     }
  165.     public function setParent(?self $parent): self
  166.     {
  167.         $this->parent $parent;
  168.         return $this;
  169.     }
  170.     public function getC1Id(): ?string
  171.     {
  172.         return $this->c1id;
  173.     }
  174.     public function setC1Id(?string $c1id): self
  175.     {
  176.         $this->c1id $c1id;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return Collection<int, IncomingInvoice>
  181.      */
  182.     public function getIncomingInvoices(): Collection
  183.     {
  184.         return $this->incomingInvoices;
  185.     }
  186.     public function addIncomingInvoice(IncomingInvoice $incomingInvoice): self
  187.     {
  188.         if (!$this->incomingInvoices->contains($incomingInvoice)) {
  189.             $this->incomingInvoices->add($incomingInvoice);
  190.             $incomingInvoice->setStorage($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeIncomingInvoice(IncomingInvoice $incomingInvoice): self
  195.     {
  196.         if ($this->incomingInvoices->removeElement($incomingInvoice)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($incomingInvoice->getStorage() === $this) {
  199.                 $incomingInvoice->setStorage(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection<int, IncomingInvoiceProduct>
  206.      */
  207.     public function getIncomingInvoiceProducts(): Collection
  208.     {
  209.         return $this->incomingInvoiceProducts;
  210.     }
  211.     public function addIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
  212.     {
  213.         if (!$this->incomingInvoiceProducts->contains($incomingInvoiceProduct)) {
  214.             $this->incomingInvoiceProducts->add($incomingInvoiceProduct);
  215.             $incomingInvoiceProduct->setStorage($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
  220.     {
  221.         if ($this->incomingInvoiceProducts->removeElement($incomingInvoiceProduct)) {
  222.             // set the owning side to null (unless already changed)
  223.             if ($incomingInvoiceProduct->getStorage() === $this) {
  224.                 $incomingInvoiceProduct->setStorage(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     /**
  230.      * @return Collection<int, Orders>
  231.      */
  232.     public function getOrders(): Collection
  233.     {
  234.         return $this->orders;
  235.     }
  236.     public function addOrder(Orders $order): self
  237.     {
  238.         if (!$this->orders->contains($order)) {
  239.             $this->orders->add($order);
  240.             $order->setStorage($this);
  241.         }
  242.         return $this;
  243.     }
  244.     public function removeOrder(Orders $order): self
  245.     {
  246.         if ($this->orders->removeElement($order)) {
  247.             // set the owning side to null (unless already changed)
  248.             if ($order->getStorage() === $this) {
  249.                 $order->setStorage(null);
  250.             }
  251.         }
  252.         return $this;
  253.     }
  254.     #[ORM\PrePersist]
  255.     public function setCreatedAtValue(): void
  256.     {
  257.         $this->date_entered = new \DateTime();
  258.     }
  259.     // #[ORM\PrePersist]
  260.     #[ORM\PreUpdate]
  261.     public function setUpdatedAtValue(): void
  262.     {
  263.         $this->date_modified = new \DateTime();
  264.     }
  265.     public function getCode1c(): ?string
  266.     {
  267.         return $this->code1c;
  268.     }
  269.     public function setCode1c(?string $code1c): self
  270.     {
  271.         $this->code1c $code1c;
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return Collection<int, Products>
  276.      */
  277.     public function getProducts(): Collection
  278.     {
  279.         return $this->products;
  280.     }
  281.     public function addProduct(Products $product): self
  282.     {
  283.         if (!$this->products->contains($product)) {
  284.             $this->products->add($product);
  285.             $product->setStorage($this);
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeProduct(Products $product): self
  290.     {
  291.         if ($this->products->removeElement($product)) {
  292.             // set the owning side to null (unless already changed)
  293.             if ($product->getStorage() === $this) {
  294.                 $product->setStorage(null);
  295.             }
  296.         }
  297.         return $this;
  298.     }
  299.     /**
  300.      * @return Collection<int, StorageElement>
  301.      */
  302.     public function getStorageElements(): Collection
  303.     {
  304.         return $this->storageElements;
  305.     }
  306.     public function addStorageElement(StorageElement $storageElement): self
  307.     {
  308.         if (!$this->storageElements->contains($storageElement)) {
  309.             $this->storageElements->add($storageElement);
  310.             $storageElement->setStorage($this);
  311.         }
  312.         return $this;
  313.     }
  314.     public function removeStorageElement(StorageElement $storageElement): self
  315.     {
  316.         if ($this->storageElements->removeElement($storageElement)) {
  317.             // set the owning side to null (unless already changed)
  318.             if ($storageElement->getStorage() === $this) {
  319.                 $storageElement->setStorage(null);
  320.             }
  321.         }
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return Collection<int, ProductBalanceInStorage>
  326.      */
  327.     public function getProductBalanceInStorages(): Collection
  328.     {
  329.         return $this->productBalanceInStorages;
  330.     }
  331.     public function addProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  332.     {
  333.         if (!$this->productBalanceInStorages->contains($productBalanceInStorage)) {
  334.             $this->productBalanceInStorages->add($productBalanceInStorage);
  335.             $productBalanceInStorage->setStorage($this);
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  340.     {
  341.         if ($this->productBalanceInStorages->removeElement($productBalanceInStorage)) {
  342.             // set the owning side to null (unless already changed)
  343.             if ($productBalanceInStorage->getStorage() === $this) {
  344.                 $productBalanceInStorage->setStorage(null);
  345.             }
  346.         }
  347.         return $this;
  348.     }
  349.     /**
  350.      * @return Collection<int, Location>
  351.      */
  352.     public function getLocation(): Collection
  353.     {
  354.         return $this->location;
  355.     }
  356.     public function addLocation(Location $location): self
  357.     {
  358.         if (!$this->location->contains($location)) {
  359.             $this->location->add($location);
  360.         }
  361.         return $this;
  362.     }
  363.     public function removeLocation(Location $location): self
  364.     {
  365.         $this->location->removeElement($location);
  366.         return $this;
  367.     }
  368.     /**
  369.      * @return Collection<int, OrderProduct>
  370.      */
  371.     public function getOrderProducts(): Collection
  372.     {
  373.         return $this->orderProducts;
  374.     }
  375.     public function addOrderProduct(OrderProduct $orderProduct): static
  376.     {
  377.         if (!$this->orderProducts->contains($orderProduct)) {
  378.             $this->orderProducts->add($orderProduct);
  379.             $orderProduct->setStorage($this);
  380.         }
  381.         return $this;
  382.     }
  383.     public function removeOrderProduct(OrderProduct $orderProduct): static
  384.     {
  385.         if ($this->orderProducts->removeElement($orderProduct)) {
  386.             // set the owning side to null (unless already changed)
  387.             if ($orderProduct->getStorage() === $this) {
  388.                 $orderProduct->setStorage(null);
  389.             }
  390.         }
  391.         return $this;
  392.     }
  393. }