src/Flexy/StockBundle/Entity/Document.php line 14

  1. <?php
  2. namespace App\Flexy\StockBundle\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Order\Order;
  5. use App\Flexy\StockBundle\Repository\DocumentRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ApiResource]
  10. #[ORM\Entity(repositoryClassDocumentRepository::class)]
  11. class Document extends Order
  12. {
  13.     #[ORM\OneToMany(targetEntityStock::class, mappedBy'document')]
  14.     private \Doctrine\Common\Collections\Collection|array $stocks;
  15.     #[ORM\Column(type'string'length255)]
  16.     private ?string $type null;
  17.     public function __construct()
  18.     {
  19.         $this->stocks = new ArrayCollection();
  20.     }
  21.     /**
  22.      * @return Collection|Stock[]
  23.      */
  24.     public function getStocks(): Collection
  25.     {
  26.         return $this->stocks;
  27.     }
  28.     public function addStock(Stock $stock): self
  29.     {
  30.         if (!$this->stocks->contains($stock)) {
  31.             $this->stocks[] = $stock;
  32.             $stock->setDocument($this);
  33.         }
  34.         return $this;
  35.     }
  36.     public function removeStock(Stock $stock): self
  37.     {
  38.         if ($this->stocks->removeElement($stock)) {
  39.             // set the owning side to null (unless already changed)
  40.             if ($stock->getDocument() === $this) {
  41.                 $stock->setDocument(null);
  42.             }
  43.         }
  44.         return $this;
  45.     }
  46.     public function getType(): ?string
  47.     {
  48.         return $this->type;
  49.     }
  50.     public function setType(string $type): self
  51.     {
  52.         $this->type $type;
  53.         return $this;
  54.     }
  55. }