<?php
namespace App\Entity;
use App\Repository\ShoppingCartRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ShoppingCartRepository::class)
*/
class ShoppingCart
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Articles::class, inversedBy="shoppingCarts")
*/
private $article;
/**
* @ORM\ManyToOne(targetEntity=Establishments::class, inversedBy="shoppingCarts")
*/
private $establishment;
/**
* @ORM\Column(type="float")
*/
private $quantity = 0.0;
/**
* @ORM\Column(type="float")
*/
private $priceUnit = 0.0;
/**
* @ORM\Column(type="float")
*/
private $tax = 0.0;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="shoppingCarts")
*/
private $createdBy;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="shoppingCartsUsers")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="shppingCartsUpdatedBy")
*/
private $updatedBy;
/**
* @ORM\Column(type="boolean")
*/
private $deleted = false;
/**
* @ORM\OneToMany(targetEntity=BackOrder::class, mappedBy="shoppingCart")
*/
private $backOrders;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->backOrders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getArticle(): ?Articles
{
return $this->article;
}
public function setArticle(?Articles $article): self
{
$this->article = $article;
return $this;
}
public function getEstablishment(): ?Establishments
{
return $this->establishment;
}
public function setEstablishment(?Establishments $establishment): self
{
$this->establishment = $establishment;
return $this;
}
public function getQuantity(): ?float
{
return $this->quantity;
}
public function setQuantity(float $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getPriceUnit(): ?float
{
return $this->priceUnit;
}
public function setPriceUnit(float $priceUnit): self
{
$this->priceUnit = $priceUnit;
return $this;
}
public function getTax(): ?float
{
return $this->tax;
}
public function setTax(float $tax): self
{
$this->tax = $tax;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?Users
{
return $this->createdBy;
}
public function setCreatedBy(?Users $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUser(): ?Users
{
return $this->user;
}
public function setUser(?Users $user): self
{
$this->user = $user;
return $this;
}
public function getUpdatedBy(): ?Users
{
return $this->updatedBy;
}
public function setUpdatedBy(?Users $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function isDeleted(): ?bool
{
return $this->deleted;
}
public function setDeleted(bool $deleted): self
{
$this->deleted = $deleted;
return $this;
}
/**
* @return Collection<int, BackOrder>
*/
public function getBackOrders(): Collection
{
return $this->backOrders;
}
public function addBackOrder(BackOrder $backOrder): self
{
if (!$this->backOrders->contains($backOrder)) {
$this->backOrders[] = $backOrder;
$backOrder->setShoppingCart($this);
}
return $this;
}
public function removeBackOrder(BackOrder $backOrder): self
{
if ($this->backOrders->removeElement($backOrder)) {
// set the owning side to null (unless already changed)
if ($backOrder->getShoppingCart() === $this) {
$backOrder->setShoppingCart(null);
}
}
return $this;
}
}