This commit is contained in:
76
src/Entity/Products.php
Normal file
76
src/Entity/Products.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ProductsRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ProductsRepository::class)]
|
||||
class Products
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::GUID, nullable: true)]
|
||||
private ?string $shopware_id = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'prod_id', targetEntity: Stock::class)]
|
||||
private Collection $stocks;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->stocks = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getShopwareId(): ?string
|
||||
{
|
||||
return $this->shopware_id;
|
||||
}
|
||||
|
||||
public function setShopwareId(?string $shopware_id): self
|
||||
{
|
||||
$this->shopware_id = $shopware_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Stock>
|
||||
*/
|
||||
public function getStocks(): Collection
|
||||
{
|
||||
return $this->stocks;
|
||||
}
|
||||
|
||||
public function addStock(Stock $stock): self
|
||||
{
|
||||
if (!$this->stocks->contains($stock)) {
|
||||
$this->stocks->add($stock);
|
||||
$stock->setProdId($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeStock(Stock $stock): self
|
||||
{
|
||||
if ($this->stocks->removeElement($stock)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($stock->getProdId() === $this) {
|
||||
$stock->setProdId(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class Stock
|
||||
private $id;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private $product_id;
|
||||
private $gtin;
|
||||
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private $stock;
|
||||
@@ -25,19 +25,22 @@ class Stock
|
||||
#[ORM\ManyToOne(targetEntity: Warehouse::class, inversedBy: 'warehouse_id')]
|
||||
private $warehouse_id;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'stocks')]
|
||||
private ?Products $prod_id = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getProductId(): ?string
|
||||
public function getGtin(): ?string
|
||||
{
|
||||
return $this->product_id;
|
||||
return $this->gtin;
|
||||
}
|
||||
|
||||
public function setProductId(string $product_id): self
|
||||
public function setGtin(string $gtin): self
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
$this->gtin = $gtin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -77,4 +80,16 @@ class Stock
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProdId(): ?Products
|
||||
{
|
||||
return $this->prod_id;
|
||||
}
|
||||
|
||||
public function setProdId(?Products $prod_id): self
|
||||
{
|
||||
$this->prod_id = $prod_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user