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