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'])]
  61.     private ?string $code1c null;
  62.     #[ORM\OneToMany(mappedBy'storage'targetEntityProducts::class)]
  63.     private Collection $products;
  64.     #[Groups(['storage:read''storage:write''product:read'])]
  65.     #[ORM\OneToMany(mappedBy'storage'targetEntityStorageElement::class)]
  66.     private Collection $storageElements;
  67.     #[ORM\OneToMany(mappedBy'storage'targetEntityProductBalanceInStorage::class)]
  68.     private Collection $productBalanceInStorages;
  69.     public function __construct()
  70.     {
  71.         $this->incomingInvoices = new ArrayCollection();
  72.         $this->incomingInvoiceProducts = new ArrayCollection();
  73.         $this->orders = new ArrayCollection();
  74.         $this->products = new ArrayCollection();
  75.         $this->storageElements = new ArrayCollection();
  76.         $this->productBalanceInStorages = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(?string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getDateEntered(): ?\DateTimeInterface
  92.     {
  93.         return $this->date_entered;
  94.     }
  95.     public function setDateEntered(?\DateTimeInterface $date_entered): self
  96.     {
  97.         $this->date_entered $date_entered;
  98.         return $this;
  99.     }
  100.     public function getDateModified(): ?\DateTimeInterface
  101.     {
  102.         return $this->date_modified;
  103.     }
  104.     public function setDateModified(?\DateTimeInterface $date_modified): self
  105.     {
  106.         $this->date_modified $date_modified;
  107.         return $this;
  108.     }
  109.     public function getCreatedBy(): ?User
  110.     {
  111.         return $this->created_by;
  112.     }
  113.     public function setCreatedBy(?User $created_by): self
  114.     {
  115.         $this->created_by $created_by;
  116.         return $this;
  117.     }
  118.     public function getModifiedUser(): ?User
  119.     {
  120.         return $this->modified_user;
  121.     }
  122.     public function setModifiedUser(?User $modified_user): self
  123.     {
  124.         $this->modified_user $modified_user;
  125.         return $this;
  126.     }
  127.     public function getStatus(): ?string
  128.     {
  129.         return $this->status;
  130.     }
  131.     public function setStatus(?string $status): self
  132.     {
  133.         $this->status $status;
  134.         return $this;
  135.     }
  136.     public function getDescription(): ?string
  137.     {
  138.         return $this->description;
  139.     }
  140.     public function setDescription(?string $description): self
  141.     {
  142.         $this->description $description;
  143.         return $this;
  144.     }
  145.     public function getStockId(): ?string
  146.     {
  147.         return $this->stock_id;
  148.     }
  149.     public function setStockId(?string $stock_id): self
  150.     {
  151.         $this->stock_id $stock_id;
  152.         return $this;
  153.     }
  154.     public function getParent(): ?self
  155.     {
  156.         return $this->parent;
  157.     }
  158.     public function setParent(?self $parent): self
  159.     {
  160.         $this->parent $parent;
  161.         return $this;
  162.     }
  163.     public function getC1Id(): ?string
  164.     {
  165.         return $this->c1id;
  166.     }
  167.     public function setC1Id(?string $c1id): self
  168.     {
  169.         $this->c1id $c1id;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return Collection<int, IncomingInvoice>
  174.      */
  175.     public function getIncomingInvoices(): Collection
  176.     {
  177.         return $this->incomingInvoices;
  178.     }
  179.     public function addIncomingInvoice(IncomingInvoice $incomingInvoice): self
  180.     {
  181.         if (!$this->incomingInvoices->contains($incomingInvoice)) {
  182.             $this->incomingInvoices->add($incomingInvoice);
  183.             $incomingInvoice->setStorage($this);
  184.         }
  185.         return $this;
  186.     }
  187.     public function removeIncomingInvoice(IncomingInvoice $incomingInvoice): self
  188.     {
  189.         if ($this->incomingInvoices->removeElement($incomingInvoice)) {
  190.             // set the owning side to null (unless already changed)
  191.             if ($incomingInvoice->getStorage() === $this) {
  192.                 $incomingInvoice->setStorage(null);
  193.             }
  194.         }
  195.         return $this;
  196.     }
  197.     /**
  198.      * @return Collection<int, IncomingInvoiceProduct>
  199.      */
  200.     public function getIncomingInvoiceProducts(): Collection
  201.     {
  202.         return $this->incomingInvoiceProducts;
  203.     }
  204.     public function addIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
  205.     {
  206.         if (!$this->incomingInvoiceProducts->contains($incomingInvoiceProduct)) {
  207.             $this->incomingInvoiceProducts->add($incomingInvoiceProduct);
  208.             $incomingInvoiceProduct->setStorage($this);
  209.         }
  210.         return $this;
  211.     }
  212.     public function removeIncomingInvoiceProduct(IncomingInvoiceProduct $incomingInvoiceProduct): self
  213.     {
  214.         if ($this->incomingInvoiceProducts->removeElement($incomingInvoiceProduct)) {
  215.             // set the owning side to null (unless already changed)
  216.             if ($incomingInvoiceProduct->getStorage() === $this) {
  217.                 $incomingInvoiceProduct->setStorage(null);
  218.             }
  219.         }
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, Orders>
  224.      */
  225.     public function getOrders(): Collection
  226.     {
  227.         return $this->orders;
  228.     }
  229.     public function addOrder(Orders $order): self
  230.     {
  231.         if (!$this->orders->contains($order)) {
  232.             $this->orders->add($order);
  233.             $order->setStorage($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeOrder(Orders $order): self
  238.     {
  239.         if ($this->orders->removeElement($order)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($order->getStorage() === $this) {
  242.                 $order->setStorage(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247.     #[ORM\PrePersist]
  248.     public function setCreatedAtValue(): void
  249.     {
  250.         $this->date_entered = new \DateTime();
  251.     }
  252.     // #[ORM\PrePersist]
  253.     #[ORM\PreUpdate]
  254.     public function setUpdatedAtValue(): void
  255.     {
  256.         $this->date_modified = new \DateTime();
  257.     }
  258.     public function getCode1c(): ?string
  259.     {
  260.         return $this->code1c;
  261.     }
  262.     public function setCode1c(?string $code1c): self
  263.     {
  264.         $this->code1c $code1c;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return Collection<int, Products>
  269.      */
  270.     public function getProducts(): Collection
  271.     {
  272.         return $this->products;
  273.     }
  274.     public function addProduct(Products $product): self
  275.     {
  276.         if (!$this->products->contains($product)) {
  277.             $this->products->add($product);
  278.             $product->setStorage($this);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeProduct(Products $product): self
  283.     {
  284.         if ($this->products->removeElement($product)) {
  285.             // set the owning side to null (unless already changed)
  286.             if ($product->getStorage() === $this) {
  287.                 $product->setStorage(null);
  288.             }
  289.         }
  290.         return $this;
  291.     }
  292.     /**
  293.      * @return Collection<int, StorageElement>
  294.      */
  295.     public function getStorageElements(): Collection
  296.     {
  297.         return $this->storageElements;
  298.     }
  299.     public function addStorageElement(StorageElement $storageElement): self
  300.     {
  301.         if (!$this->storageElements->contains($storageElement)) {
  302.             $this->storageElements->add($storageElement);
  303.             $storageElement->setStorage($this);
  304.         }
  305.         return $this;
  306.     }
  307.     public function removeStorageElement(StorageElement $storageElement): self
  308.     {
  309.         if ($this->storageElements->removeElement($storageElement)) {
  310.             // set the owning side to null (unless already changed)
  311.             if ($storageElement->getStorage() === $this) {
  312.                 $storageElement->setStorage(null);
  313.             }
  314.         }
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection<int, ProductBalanceInStorage>
  319.      */
  320.     public function getProductBalanceInStorages(): Collection
  321.     {
  322.         return $this->productBalanceInStorages;
  323.     }
  324.     public function addProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  325.     {
  326.         if (!$this->productBalanceInStorages->contains($productBalanceInStorage)) {
  327.             $this->productBalanceInStorages->add($productBalanceInStorage);
  328.             $productBalanceInStorage->setStorage($this);
  329.         }
  330.         return $this;
  331.     }
  332.     public function removeProductBalanceInStorage(ProductBalanceInStorage $productBalanceInStorage): self
  333.     {
  334.         if ($this->productBalanceInStorages->removeElement($productBalanceInStorage)) {
  335.             // set the owning side to null (unless already changed)
  336.             if ($productBalanceInStorage->getStorage() === $this) {
  337.                 $productBalanceInStorage->setStorage(null);
  338.             }
  339.         }
  340.         return $this;
  341.     }
  342. }