src/Entity/Order.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\traits\base64Field;
  4. use App\Entity\traits\Timestapable;
  5. use App\Entity\traits\UniqueCode;
  6. use App\Repository\OrderRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  11. use Doctrine\ORM\Mapping\PrePersist;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Uid\Uuid;
  14. #[ORM\Entity(repositoryClassOrderRepository::class)]
  15. #[ORM\Table(name'`order`')]
  16. #[HasLifecycleCallbacks]
  17. class Order
  18. {
  19.     CONST ORDER_TYPE_RESTO="Restaurant";
  20.     CONST ORDER_TYPE_SUBSCRIPTION="Souscription";
  21.     CONST ORDER_TYPE_SUBSCRIPTION_COOKER="Souscription Cooker";
  22.     CONST ORDER_TYPE_COURSE="Souscription Cours";
  23.     use Timestapable;
  24.     use base64Field;
  25.     use UniqueCode;
  26.     
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     #[Groups(["show_order""user_info"'show_course'])]
  31.     private ?int $id null;
  32.     #[ORM\ManyToOne(inversedBy'orders')]
  33.     #[Groups(["show_order","show_course"])]
  34.     private ?User $user null;
  35.     #[ORM\Column(nullabletrue)]
  36.     #[Groups(["show_order""user_info"'show_course'])]
  37.     private ?bool $is_waiting null;
  38.     #[ORM\Column]
  39.     #[Groups(["show_order""user_info"'show_course''show_subscription'])]
  40.     private ?bool $is_paid null;
  41.     #[ORM\Column(length255nullable:true)]
  42.     #[Groups(["show_order""user_info"'show_course''show_subscription'])]
  43.     private ?string $currency_code null;
  44.     #[ORM\Column(length255 nullable:true)]
  45.     #[Groups(["show_order""user_info"'show_course'])]
  46.     private ?string $currency_name null;
  47.     #[ORM\Column(length255)]
  48.     #[Groups(["show_order""user_info"'show_course''show_subscription'])]
  49.     private ?string $amount null;
  50.     #[ORM\Column(length255)]
  51.     #[Groups(["show_order""user_info"'show_course'])]
  52.     private ?string $tax null;
  53.     #[ORM\Column]
  54.     #[Groups(["show_order""user_info"'show_course'])]
  55.     private ?int $orderStatus null;
  56.     #[ORM\Column(nullable:true)]
  57.     #[Groups(["show_order""user_info"'show_course''show_subscription'])]
  58.     private ?string $reference null;
  59.     #[ORM\OneToMany(mappedBy'orderInvoice'targetEntityInvoice::class)]
  60.     #[Groups(["show_order""user_info"'show_course'])]
  61.     private Collection $invoices;
  62.     #[ORM\Column(length255)]
  63.     #[Groups(["show_order""user_info"'show_course'])]
  64.     private ?string $total_amount null;
  65.     #[ORM\OneToMany(mappedBy'commande'targetEntityOrderItems::class)]
  66.     #[Groups(["show_order""user_info"'show_course'])]
  67.     private Collection $OrderItems;
  68.     #[ORM\ManyToOne(inversedBy'orders')]
  69.     #[Groups(["show_order""user_info"'show_course'])]
  70.     private ?Restaurant $resto null;
  71.     #[ORM\Column(length255)]
  72.     #[Groups(["show_order""user_info"'show_course'])]
  73.     private ?string $OrderStatusStr null;
  74.     #[ORM\Column(length255)]
  75.     private ?string $referenceApaym null;
  76.     #[ORM\Column(length255)]
  77.     private ?string $orderPaymentStatus null;
  78.     #[ORM\OneToMany(mappedBy'commande'targetEntityOrderHistory::class)]
  79.     private Collection $orderHistories;
  80.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  81.     #[Groups(["show_order""user_info"'show_course'])]
  82.     private ?OrderDelivery $orderDelivery;
  83.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  84.     #[Groups(["show_order"])]
  85.     private ?Course $course;
  86.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  87.     #[Groups(["show_order"])]
  88.     private ?Subscription $subscription null;
  89.     #[ORM\Column(length255)]
  90.     #[Groups(["show_order""user_info"])]
  91.     private ?string $commandeType null;
  92.     public function __construct()
  93.     {
  94.         $this->invoices = new ArrayCollection();
  95.         $this->OrderItems = new ArrayCollection();
  96.         $this->orderHistories = new ArrayCollection();
  97.     }
  98.     #[PrePersist]
  99.     public function addUniqueCode(){
  100.         $this->uuid Uuid::v1();
  101.     }
  102.     
  103.     public function getId(): ?int
  104.     {
  105.         return $this->id;
  106.     }
  107.     public function getUser(): ?user
  108.     {
  109.         return $this->user;
  110.     }
  111.     public function setUser(?user $user): self
  112.     {
  113.         $this->user $user;
  114.         return $this;
  115.     }
  116.     public function isIsWaiting(): ?bool
  117.     {
  118.         return $this->is_waiting;
  119.     }
  120.     public function setIsWaiting(?bool $is_waiting): self
  121.     {
  122.         $this->is_waiting $is_waiting;
  123.         return $this;
  124.     }
  125.     public function isIsPaid(): ?bool
  126.     {
  127.         return $this->is_paid;
  128.     }
  129.     public function setIsPaid(bool $is_paid): self
  130.     {
  131.         $this->is_paid $is_paid;
  132.         return $this;
  133.     }
  134.     public function getCurrencyCode(): ?string
  135.     {
  136.         return $this->currency_code;
  137.     }
  138.     public function setCurrencyCode(string $currency_code): self
  139.     {
  140.         $this->currency_code $currency_code;
  141.         return $this;
  142.     }
  143.     public function getCurrencyName(): ?string
  144.     {
  145.         return $this->currency_name;
  146.     }
  147.     public function setCurrencyName(string $currency_name): self
  148.     {
  149.         $this->currency_name $currency_name;
  150.         return $this;
  151.     }
  152.     public function getAmount(): ?string
  153.     {
  154.         return $this->amount;
  155.     }
  156.     public function setAmount(string $amount): self
  157.     {
  158.         $this->amount $amount;
  159.         return $this;
  160.     }
  161.     public function getOrderStatus(): ?int
  162.     {
  163.         return $this->orderStatus;
  164.     }
  165.     public function setOrderStatus(int $orderStatus): self
  166.     {
  167.         $this->orderStatus $orderStatus;
  168.         return $this;
  169.     }
  170.     public function getReference(): ?string
  171.     {
  172.         return $this->reference;
  173.     }
  174.     public function setReference(string $reference): self
  175.     {
  176.         $this->reference $reference;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return Collection<int, Invoice>
  181.      */
  182.     public function getInvoices(): Collection
  183.     {
  184.         return $this->invoices;
  185.     }
  186.     public function addInvoice(Invoice $invoice): self
  187.     {
  188.         if (!$this->invoices->contains($invoice)) {
  189.             $this->invoices->add($invoice);
  190.             $invoice->setOrderInvoice($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeInvoice(Invoice $invoice): self
  195.     {
  196.         if ($this->invoices->removeElement($invoice)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($invoice->getOrderInvoice() === $this) {
  199.                 $invoice->setOrderInvoice(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     public function getTotalAmount(): ?string
  205.     {
  206.         return $this->total_amount;
  207.     }
  208.     public function setTotalAmount(string $total_amount): self
  209.     {
  210.         $this->total_amount $total_amount;
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection<int, OrderItems>
  215.      */
  216.     public function getOrderItems(): Collection
  217.     {
  218.         return $this->OrderItems;
  219.     }
  220.     public function addOrderItem(OrderItems $orderItem): self
  221.     {
  222.         if (!$this->OrderItems->contains($orderItem)) {
  223.             $this->OrderItems->add($orderItem);
  224.             $orderItem->setCommande($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeOrderItem(OrderItems $orderItem): self
  229.     {
  230.         if ($this->OrderItems->removeElement($orderItem)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($orderItem->getCommande() === $this) {
  233.                 $orderItem->setCommande(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     public function getResto(): ?Restaurant
  239.     {
  240.         return $this->resto;
  241.     }
  242.     public function setResto(?Restaurant $resto): self
  243.     {
  244.         $this->resto $resto;
  245.         return $this;
  246.     }
  247.     public function getTax()
  248.     {
  249.         return $this->tax;
  250.     }
  251.     
  252.     public function setTax($tax)
  253.     {
  254.         $this->tax $tax;
  255.         return $this;
  256.     }
  257.     public function getOrderStatusStr(): ?string
  258.     {
  259.         return $this->OrderStatusStr;
  260.     }
  261.     public function setOrderStatusStr(string $OrderStatusStr): self
  262.     {
  263.         $this->OrderStatusStr $OrderStatusStr;
  264.         return $this;
  265.     }
  266.     public function getReferenceApaym(): ?string
  267.     {
  268.         return $this->referenceApaym;
  269.     }
  270.     public function setReferenceApaym(string $referenceApaym): self
  271.     {
  272.         $this->referenceApaym $referenceApaym;
  273.         return $this;
  274.     }
  275.     public function getOrderPaymentStatus(): ?string
  276.     {
  277.         return $this->orderPaymentStatus;
  278.     }
  279.     public function setOrderPaymentStatus(string $orderPaymentStatus): self
  280.     {
  281.         $this->orderPaymentStatus $orderPaymentStatus;
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return Collection<int, OrderHistory>
  286.      */
  287.     public function getOrderHistories(): Collection
  288.     {
  289.         return $this->orderHistories;
  290.     }
  291.     public function addOrderHistory(OrderHistory $orderHistory): self
  292.     {
  293.         if (!$this->orderHistories->contains($orderHistory)) {
  294.             $this->orderHistories->add($orderHistory);
  295.             $orderHistory->setCommande($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeOrderHistory(OrderHistory $orderHistory): self
  300.     {
  301.         if ($this->orderHistories->removeElement($orderHistory)) {
  302.             // set the owning side to null (unless already changed)
  303.             if ($orderHistory->getCommande() === $this) {
  304.                 $orderHistory->setCommande(null);
  305.             }
  306.         }
  307.         return $this;
  308.     }
  309.     public function getOrderDelivery(){
  310.         return $this->orderDelivery;
  311.     }
  312.     public function setOrderDelivery(OrderDelivery $orderDelivery)
  313.     {
  314.         $this->orderDelivery $orderDelivery;
  315.         return $this;
  316.     }
  317.     
  318.     public function setCourse($course)
  319.     {
  320.         $this->course $course;
  321.         return $this;
  322.     }
  323.     
  324.     public function getCourse()
  325.     {
  326.         return $this->course;
  327.     }
  328.     public function getSubscription()
  329.     {
  330.         return $this->subscription;
  331.     }
  332.     public function setSubscription($subscription) : self
  333.     {
  334.         $this->subscription $subscription;
  335.         return $this;
  336.     }
  337.     public function getCommandeType(): ?string
  338.     {
  339.         return $this->commandeType;
  340.     }
  341.     public function setCommandeType(string $commandeType): self
  342.     {
  343.         $this->commandeType $commandeType;
  344.         return $this;
  345.     }
  346. }