<?php
namespace App\Entity\Security;
use App\Entity\App\Product;
use App\Repository\Security\OrderRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
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\ManyToMany(targetEntity: Product::class, inversedBy: 'orders')]
private Collection $products;
#[ORM\Column]
private ?\DateTimeImmutable $orderAt = null;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $status = null;
#[ORM\Column]
private ?float $price = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $customization = null;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): static
{
if (!$this->products->contains($product)) {
$this->products->add($product);
}
return $this;
}
public function removeProduct(Product $product): static
{
$this->products->removeElement($product);
return $this;
}
public function getOrderAt(): ?\DateTimeImmutable
{
return $this->orderAt;
}
public function setOrderAt(\DateTimeImmutable $orderAt): static
{
$this->orderAt = $orderAt;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): static
{
$this->status = $status;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): static
{
$this->price = $price;
return $this;
}
public function getCustomization(): ?string
{
return $this->customization;
}
public function setCustomization(?string $customization): static
{
$this->customization = $customization;
return $this;
}
}