src/Entity/Warehouses.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WarehousesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=WarehousesRepository::class)
  10.  */
  11. class Warehouses
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups({
  18.      *     "warehouse@core"
  19.      * })
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=64)
  24.      * @Groups({
  25.      *      "warehouse@core"
  26.      *  })
  27.      */
  28.     private $name;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="warehouses")
  31.      * @ORM\JoinColumn(nullable=false)
  32.      * @Groups({
  33.      *      "warehouse@location"
  34.      *  })
  35.      */
  36.     private $location;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="warehouses")
  39.      * @ORM\JoinColumn(nullable=false)
  40.      * @Groups({
  41.      *      "warehouse@creator"
  42.      *  })
  43.      */
  44.     private $creator;
  45.     /**
  46.      * @ORM\Column(type="datetime_immutable")
  47.      * @Groups({
  48.      *      "warehouse@core"
  49.      *  })
  50.      */
  51.     private $created_at;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="warehouse")
  54.      */
  55.     private $stocks;
  56.     public function __construct()
  57.     {
  58.         $this->stocks = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getLocation(): ?Locations
  74.     {
  75.         return $this->location;
  76.     }
  77.     public function setLocation(?Locations $location): self
  78.     {
  79.         $this->location $location;
  80.         return $this;
  81.     }
  82.     public function getCreator(): ?User
  83.     {
  84.         return $this->creator;
  85.     }
  86.     public function setCreator(?User $creator): self
  87.     {
  88.         $this->creator $creator;
  89.         return $this;
  90.     }
  91.     public function getCreatedAt(): ?\DateTimeImmutable
  92.     {
  93.         return $this->created_at;
  94.     }
  95.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  96.     {
  97.         $this->created_at $created_at;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, Stocks>
  102.      */
  103.     public function getStocks(): Collection
  104.     {
  105.         return $this->stocks;
  106.     }
  107.     public function addStock(Stocks $stock): self
  108.     {
  109.         if (!$this->stocks->contains($stock)) {
  110.             $this->stocks[] = $stock;
  111.             $stock->setWarehouse($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeStock(Stocks $stock): self
  116.     {
  117.         if ($this->stocks->removeElement($stock)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($stock->getWarehouse() === $this) {
  120.                 $stock->setWarehouse(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125. }