<?php
/**
* @author Léo BANNHOLTZER (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\StocksBundle\Entity;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use Bluue\StocksBundle\Repository\StockOrderLineRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Table(name="stocks_bundle__stock_order_line",
* indexes={
* @ORM\Index(name="quantity", columns={"quantity"}),
* @ORM\Index(name="quantity_available", columns={"quantity_available"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @ORM\Entity(repositoryClass=StockOrderLineRepository::class)
*/
class StockOrderLine
{
use UserTimestampableEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @ORM\ManyToOne(targetEntity=StockProduct::class, inversedBy="stockOrderLines")
*/
private ?StockProduct $stockProduct;
/**
* @ORM\Column(type="integer")
*/
private ?int $quantity;
/**
* @ORM\Column(type="integer")
*/
private ?int $quantity_available;
/**
* @ORM\OneToMany(
* targetEntity=StockOrderLineLocation::class,
* mappedBy="stockOrderLine",
* orphanRemoval=true,
* cascade={"persist", "remove"},
* fetch="EXTRA_LAZY")
*/
private Collection $stockOrderLineLocations;
private ?object $orderLine;
public function __construct()
{
$this->stockOrderLineLocations = new ArrayCollection();
}
public function getId(): ?Uuid
{
return $this->id;
}
public function setOrderLine(object $orderLine)
{
$this->orderLine = $orderLine;
}
public function getOrderLine(): ?object
{
return $this->orderLine;
}
public function getStockProduct(): ?StockProduct
{
return $this->stockProduct;
}
public function setStockProduct(?StockProduct $StockProduct): self
{
$this->stockProduct = $StockProduct;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getQuantityAvailable(): ?int
{
return $this->quantity_available;
}
public function setQuantityAvailable(int $quantity_available): self
{
$this->quantity_available = $quantity_available;
return $this;
}
/**
* @return Collection<int, StockOrderLineLocation>
*/
public function getStockOrderLineLocations(): Collection
{
return $this->stockOrderLineLocations;
}
public function addStockOrderLineLocation(StockOrderLineLocation $stockOrderLineLocation): self
{
if (!$this->stockOrderLineLocations->contains($stockOrderLineLocation)) {
$this->stockOrderLineLocations[] = $stockOrderLineLocation;
$stockOrderLineLocation->setStockOrderLine($this);
}
return $this;
}
}