src/Entity/Order.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassOrderRepository::class)]
  8. #[ORM\Table(name'`order`')]
  9. class Order
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'orders')]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private ?User $user null;
  18.     #[ORM\Column]
  19.     private ?int $orderNumber null;
  20.     #[ORM\OneToMany(mappedBy'order'targetEntityOrderProductsSizes::class, orphanRemovaltrue)]
  21.     private Collection $orderProductsSizes;
  22.     public function __construct()
  23.     {
  24.         $this->orderProductsSizes = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getUser(): ?User
  31.     {
  32.         return $this->user;
  33.     }
  34.     public function setUser(?User $user): self
  35.     {
  36.         $this->user $user;
  37.         return $this;
  38.     }
  39.     public function getOrderNumber(): ?int
  40.     {
  41.         return $this->orderNumber;
  42.     }
  43.     public function setOrderNumber(int $orderNumber): static
  44.     {
  45.         $this->orderNumber $orderNumber;
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return Collection<int, OrderProductsSizes>
  50.      */
  51.     public function getOrderProductsSizes(): Collection
  52.     {
  53.         return $this->orderProductsSizes;
  54.     }
  55.     /**
  56.      * @param OrderProductsSizes $orderProductsSize
  57.      * @return $this
  58.      */
  59.     public function addOrderProductsSize(OrderProductsSizes $orderProductsSize): static
  60.     {
  61.         if (!$this->orderProductsSizes->contains($orderProductsSize)) {
  62.             $this->orderProductsSizes->add($orderProductsSize);
  63.             $orderProductsSize->setOrder($this);
  64.         }
  65.         return $this;
  66.     }
  67.     /**
  68.      * @param OrderProductsSizes $orderProductsSize
  69.      * @return $this
  70.      */
  71.     public function removeOrderProductsSize(OrderProductsSizes $orderProductsSize): static
  72.     {
  73.         if ($this->orderProductsSizes->removeElement($orderProductsSize)) {
  74.             if ($orderProductsSize->getOrder() === $this) {
  75.                 $orderProductsSize->setOrder(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80. }