src/Entity/OrderItem.php line 10

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderItemRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. #[ORM\Entity(repositoryClassOrderItemRepository::class)]
  7. class OrderItem
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\Column]
  14.     #[Assert\NotBlank(message'Spécifiez une quantité.')]
  15.     #[Assert\GreaterThanOrEqual(value1message'La quantité doit être supérieure ou égale à 1.')]
  16.     private ?int $order_item_product_quantity null;
  17.     #[ORM\ManyToOne(inversedBy'order_items')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private ?Order $order_item_order null;
  20.     #[ORM\ManyToOne(inversedBy'order_items')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Product $order_item_product null;
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getOrderItemProductQuantity(): ?int
  28.     {
  29.         return $this->order_item_product_quantity;
  30.     }
  31.     public function setOrderItemProductQuantity(int $order_item_product_quantity): self
  32.     {
  33.         $this->order_item_product_quantity $order_item_product_quantity;
  34.         return $this;
  35.     }
  36.     public function getOrderItemOrder(): ?Order
  37.     {
  38.         return $this->order_item_order;
  39.     }
  40.     public function setOrderItemOrder(?Order $order_item_order): self
  41.     {
  42.         $this->order_item_order $order_item_order;
  43.         return $this;
  44.     }
  45.     public function getOrderItemProduct(): ?Product
  46.     {
  47.         return $this->order_item_product;
  48.     }
  49.     public function setOrderItemProduct(?Product $order_item_product): self
  50.     {
  51.         $this->order_item_product $order_item_product;
  52.         return $this;
  53.     }
  54.     public function __toString(): string
  55.     {
  56.         return $this->order_item_product_quantity ' x ' $this->order_item_product;
  57.     }
  58. }