Add Stock & Warehouse

This commit is contained in:
Marko
2022-07-01 15:31:34 +02:00
parent 460411ab43
commit a2ef85c188
9 changed files with 486 additions and 23 deletions

80
src/Entity/Stock.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
namespace App\Entity;
use App\Repository\StockRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StockRepository::class)]
class Stock
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $product_id;
#[ORM\Column(type: 'integer')]
private $stock;
#[ORM\Column(type: 'datetime', nullable: true)]
private $update_time;
#[ORM\ManyToOne(targetEntity: Warehouse::class, inversedBy: 'warehouse_id')]
private $warehouse_id;
public function getId(): ?int
{
return $this->id;
}
public function getProductId(): ?string
{
return $this->product_id;
}
public function setProductId(string $product_id): self
{
$this->product_id = $product_id;
return $this;
}
public function getStock(): ?int
{
return $this->stock;
}
public function setStock(int $stock): self
{
$this->stock = $stock;
return $this;
}
public function getUpdateTime(): ?\DateTimeInterface
{
return $this->update_time;
}
public function setUpdateTime(?\DateTimeInterface $update_time): self
{
$this->update_time = $update_time;
return $this;
}
public function getWarehouseId(): ?Warehouse
{
return $this->warehouse_id;
}
public function setWarehouseId(?Warehouse $warehouse_id): self
{
$this->warehouse_id = $warehouse_id;
return $this;
}
}

75
src/Entity/Warehouse.php Normal file
View File

@@ -0,0 +1,75 @@
<?php
namespace App\Entity;
use App\Repository\WarehouseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WarehouseRepository::class)]
class Warehouse
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\OneToMany(mappedBy: 'warehouse_id', targetEntity: Stock::class)]
private $warehouse_id;
#[ORM\Column(type: 'integer')]
private $priority;
public function __construct()
{
$this->warehouse_id = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Stock>
*/
public function getWarehouseId(): Collection
{
return $this->warehouse_id;
}
public function addWarehouseId(Stock $warehouseId): self
{
if (!$this->warehouse_id->contains($warehouseId)) {
$this->warehouse_id[] = $warehouseId;
$warehouseId->setWarehouseId($this);
}
return $this;
}
public function removeWarehouseId(Stock $warehouseId): self
{
if ($this->warehouse_id->removeElement($warehouseId)) {
// set the owning side to null (unless already changed)
if ($warehouseId->getWarehouseId() === $this) {
$warehouseId->setWarehouseId(null);
}
}
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(int $priority): self
{
$this->priority = $priority;
return $this;
}
}