<?php
namespace App\Entity;
use App\Repository\OrderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[ORM\Table(name: '`order`')]
class Order
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[ORM\Column]
private ?int $orderNumber = null;
#[ORM\OneToMany(mappedBy: 'order', targetEntity: OrderProductsSizes::class, orphanRemoval: true)]
private Collection $orderProductsSizes;
public function __construct()
{
$this->orderProductsSizes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getOrderNumber(): ?int
{
return $this->orderNumber;
}
public function setOrderNumber(int $orderNumber): static
{
$this->orderNumber = $orderNumber;
return $this;
}
/**
* @return Collection<int, OrderProductsSizes>
*/
public function getOrderProductsSizes(): Collection
{
return $this->orderProductsSizes;
}
/**
* @param OrderProductsSizes $orderProductsSize
* @return $this
*/
public function addOrderProductsSize(OrderProductsSizes $orderProductsSize): static
{
if (!$this->orderProductsSizes->contains($orderProductsSize)) {
$this->orderProductsSizes->add($orderProductsSize);
$orderProductsSize->setOrder($this);
}
return $this;
}
/**
* @param OrderProductsSizes $orderProductsSize
* @return $this
*/
public function removeOrderProductsSize(OrderProductsSizes $orderProductsSize): static
{
if ($this->orderProductsSizes->removeElement($orderProductsSize)) {
if ($orderProductsSize->getOrder() === $this) {
$orderProductsSize->setOrder(null);
}
}
return $this;
}
}