67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\OrderItemRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
|
use Symfony\Bridge\Doctrine\Types\UlidType;
|
|
use Symfony\Component\Uid\Ulid;
|
|
|
|
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
|
|
class OrderItem
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
|
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
|
private Ulid $id;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'orderItems')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private FoodOrder|null $foodOrder = null;
|
|
|
|
#[ORM\ManyToOne]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?MenuItem $menuItem = null;
|
|
|
|
#[ORM\OneToMany(mappedBy: 'orderItem', targetEntity: ItemExtra::class)]
|
|
private Collection $extras;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->id = new Ulid;
|
|
$this->extras = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): Ulid
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getFoodOrder(): FoodOrder|null
|
|
{
|
|
return $this->foodOrder;
|
|
}
|
|
|
|
public function setFoodOrder(FoodOrder|null $foodOrder): static
|
|
{
|
|
$this->foodOrder = $foodOrder;
|
|
return $this;
|
|
}
|
|
|
|
public function getMenuItem(): ?MenuItem
|
|
{
|
|
return $this->menuItem;
|
|
}
|
|
|
|
public function setMenuItem(?MenuItem $menuItem): static
|
|
{
|
|
$this->menuItem = $menuItem;
|
|
|
|
return $this;
|
|
}
|
|
|
|
}
|