src/Entity/Order.php line 13

  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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassOrderRepository::class)]
  9. #[ORM\Table(name'`order`')]
  10. class Order
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\ManyToOne(inversedBy'orders')]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private ?User $order_user null;
  19.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  20.     private ?\DateTimeInterface $order_date null;
  21.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  22.     private ?string $order_total_price null;
  23.     #[ORM\OneToMany(mappedBy'order_item_order'targetEntityOrderItem::class, cascade: ['persist''remove'], orphanRemovaltrue )]
  24.     private Collection $order_items;
  25.     #[ORM\ManyToOne(inversedBy'orders')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private ?Status $order_status null;
  28.     #[ORM\ManyToOne(inversedBy'orders')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Address $order_address null;
  31.     #[ORM\ManyToOne(inversedBy'orders')]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private ?BillingAddress $order_billing_address null;
  34.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  35.     private ?string $order_shipping_cost null;
  36.     #[ORM\Column(length25nullabletrue)]
  37.     private ?string $order_tracking_number null;
  38.     public function __construct()
  39.     {
  40.         $this->order_items = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getOrderUser(): ?User
  47.     {
  48.         return $this->order_user;
  49.     }
  50.     public function setOrderUser(?User $user): self
  51.     {
  52.         $this->order_user $user;
  53.         return $this;
  54.     }
  55.     public function getOrderDate(): ?\DateTimeInterface
  56.     {
  57.         return $this->order_date;
  58.     }
  59.     public function setOrderDate(\DateTimeInterface $order_date): self
  60.     {
  61.         $this->order_date $order_date;
  62.         return $this;
  63.     }
  64.     public function getOrderTotalPrice(): ?string
  65.     {
  66.         return $this->order_total_price;
  67.     }
  68.     public function setOrderTotalPrice(string $order_total_price): self
  69.     {
  70.         $this->order_total_price $order_total_price;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, OrderItem>
  75.      */
  76.     public function getOrderItems(): Collection
  77.     {
  78.         return $this->order_items;
  79.     }
  80.     public function addOrderItem(OrderItem $orderItem): self
  81.     {
  82.         if (!$this->order_items->contains($orderItem)) {
  83.             $this->order_items->add($orderItem);
  84.             $orderItem->setOrderItemOrder($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeOrderItem(OrderItem $orderItem): self
  89.     {
  90.         if ($this->order_items->removeElement($orderItem)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($orderItem->getOrderItemOrder() === $this) {
  93.                 $orderItem->setOrderItemOrder(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     public function getOrderStatus(): ?Status
  99.     {
  100.         return $this->order_status;
  101.     }
  102.     public function setOrderStatus(?Status $order_status): self
  103.     {
  104.         $this->order_status $order_status;
  105.         return $this;
  106.     }
  107.     public function getOrderAddress(): ?Address
  108.     {
  109.         return $this->order_address;
  110.     }
  111.     public function setOrderAddress(?Address $order_address): self
  112.     {
  113.         $this->order_address $order_address;
  114.         return $this;
  115.     }
  116.     public function getOrderBillingAddress(): ?BillingAddress
  117.     {
  118.         return $this->order_billing_address;
  119.     }
  120.     public function setOrderBillingAddress(?BillingAddress $order_billing_address): self
  121.     {
  122.         $this->order_billing_address $order_billing_address;
  123.         return $this;
  124.     }
  125.     public function getOrderShippingCost(): ?string
  126.     {
  127.         return $this->order_shipping_cost;
  128.     }
  129.     public function setOrderShippingCost(string $order_shipping_cost): self
  130.     {
  131.         $this->order_shipping_cost $order_shipping_cost;
  132.         return $this;
  133.     }
  134.     public function __toString(): string
  135.     {
  136.         return $this->id ' ' $this->order_user;
  137.     }
  138.     public function getOrderTrackingNumber(): ?string
  139.     {
  140.         return $this->order_tracking_number;
  141.     }
  142.     public function setOrderTrackingNumber(?string $order_tracking_number): self
  143.     {
  144.         $this->order_tracking_number $order_tracking_number;
  145.         return $this;
  146.     }
  147. }