src/Entity/Order.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Stripe\PaymentIntent;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\OrderRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. /**
  9.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  10.  * @ORM\HasLifecycleCallbacks 
  11.  * @ORM\Table(name="`order`")
  12.  */
  13. class Order
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")
  23.      * @ORM\JoinColumn(nullable=false)
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\Column(type="datetime")
  28.      */
  29.     private $createdAt;
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $updatedAt;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $reference;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=OrderDetails::class, mappedBy="myorder")
  40.      */
  41.     private $orderDetails;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=OrderStatus::class, inversedBy="orders")
  44.      */
  45.     private $stat;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="ordersGrossistes")
  48.      * @ORM\JoinColumn(nullable=true)
  49.      */
  50.     private $grossiste;
  51.     /**
  52.      * @ORM\Column(type="date", nullable=true)
  53.      */
  54.     private $dateprevision;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=EtatPaiement::class, inversedBy="orders")
  57.      */
  58.     private $etatpaiement;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=Typepaiement::class, inversedBy="orders")
  61.      */
  62.     private $typepaiement;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $stripeSessionId;
  67.     /**
  68.      * @ORM\Column(type="float", nullable=true)
  69.      */
  70.     private $montant_paye;
  71.     /**
  72.      * @ORM\Column(type="datetime", nullable=true)
  73.      */
  74.     private $date_last_paiement;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity=HistoriquePaiement::class, mappedBy="my_order")
  77.      */
  78.     private $historiquePaiements;
  79.     public function __construct()
  80.     {
  81.         $this->orderDetails = new ArrayCollection();
  82.         $this->createdAt = new \DateTime();
  83.         $this->historiquePaiements = new ArrayCollection();
  84.     }
  85.     /**
  86.      * Undocumented function
  87.      *
  88.      * @ORM\PrePersist
  89.      * @ORM\PreUpdate
  90.      */
  91.     public function initialiseSlug()
  92.     {
  93.         $this->updatedAt = new \DateTime();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getUser(): ?User
  100.     {
  101.         return $this->user;
  102.     }
  103.     public function setUser(?User $user): self
  104.     {
  105.         $this->user $user;
  106.         return $this;
  107.     }
  108.     public function getCreatedAt(): ?\DateTimeInterface
  109.     {
  110.         return $this->createdAt;
  111.     }
  112.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  113.     {
  114.         $this->createdAt $createdAt;
  115.         return $this;
  116.     }
  117.     public function getUpdatedAt(): ?\DateTimeInterface
  118.     {
  119.         return $this->updatedAt;
  120.     }
  121.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  122.     {
  123.         $this->updatedAt $updatedAt;
  124.         return $this;
  125.     }
  126.     public function getReference(): ?string
  127.     {
  128.         return $this->reference;
  129.     }
  130.     public function setReference(string $reference): self
  131.     {
  132.         $this->reference $reference;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return Collection<int, OrderDetails>
  137.      */
  138.     public function getOrderDetails(): Collection
  139.     {
  140.         return $this->orderDetails;
  141.     }
  142.     public function addOrderDetail(OrderDetails $orderDetail): self
  143.     {
  144.         if (!$this->orderDetails->contains($orderDetail)) {
  145.             $this->orderDetails[] = $orderDetail;
  146.             $orderDetail->setMyorder($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeOrderDetail(OrderDetails $orderDetail): self
  151.     {
  152.         if ($this->orderDetails->removeElement($orderDetail)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($orderDetail->getMyorder() === $this) {
  155.                 $orderDetail->setMyorder(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     public function getStat(): ?OrderStatus
  161.     {
  162.         return $this->stat;
  163.     }
  164.     public function setStat(?OrderStatus $stat): self
  165.     {
  166.         $this->stat $stat;
  167.         return $this;
  168.     }
  169.     public function getGrossiste(): ?User
  170.     {
  171.         return $this->grossiste;
  172.     }
  173.     public function setGrossiste(?User $grossiste): self
  174.     {
  175.         $this->grossiste $grossiste;
  176.         return $this;
  177.     }
  178.     public function getTotal()
  179.     {
  180.         $total 0;
  181.         foreach($this->getOrderDetails()->getValues() as $product){
  182.             $total += $product->getTotal(); 
  183.         }
  184.         return $total;
  185.     }
  186.     public function getDateprevision(): ?\DateTimeInterface
  187.     {
  188.         return $this->dateprevision;
  189.     }
  190.     public function setDateprevision(?\DateTimeInterface $dateprevision): self
  191.     {
  192.         $this->dateprevision $dateprevision;
  193.         return $this;
  194.     }
  195.     public function getEtatpaiement(): ?EtatPaiement
  196.     {
  197.         return $this->etatpaiement;
  198.     }
  199.     public function setEtatpaiement(?EtatPaiement $etatpaiement): self
  200.     {
  201.         $this->etatpaiement $etatpaiement;
  202.         return $this;
  203.     }
  204.     public function getTypepaiement(): ?Typepaiement
  205.     {
  206.         return $this->typepaiement;
  207.     }
  208.     public function setTypepaiement(?Typepaiement $typepaiement): self
  209.     {
  210.         $this->typepaiement $typepaiement;
  211.         return $this;
  212.     }
  213.     public function getStripeSessionId(): ?string
  214.     {
  215.         return $this->stripeSessionId;
  216.     }
  217.     public function setStripeSessionId(?string $stripeSessionId): self
  218.     {
  219.         $this->stripeSessionId $stripeSessionId;
  220.         return $this;
  221.     }
  222.     public function getMontantPaye(): ?float
  223.     {
  224.         return $this->montant_paye;
  225.     }
  226.     public function setMontantPaye(?float $montant_paye): self
  227.     {
  228.         $this->montant_paye $montant_paye;
  229.         return $this;
  230.     }
  231.     public function getDateLastPaiement(): ?\DateTimeInterface
  232.     {
  233.         return $this->date_last_paiement;
  234.     }
  235.     public function setDateLastPaiement(?\DateTimeInterface $date_last_paiement): self
  236.     {
  237.         $this->date_last_paiement $date_last_paiement;
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return Collection<int, HistoriquePaiement>
  242.      */
  243.     public function getHistoriquePaiements(): Collection
  244.     {
  245.         return $this->historiquePaiements;
  246.     }
  247.     public function addHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
  248.     {
  249.         if (!$this->historiquePaiements->contains($historiquePaiement)) {
  250.             $this->historiquePaiements[] = $historiquePaiement;
  251.             $historiquePaiement->setMyOrder($this);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeHistoriquePaiement(HistoriquePaiement $historiquePaiement): self
  256.     {
  257.         if ($this->historiquePaiements->removeElement($historiquePaiement)) {
  258.             // set the owning side to null (unless already changed)
  259.             if ($historiquePaiement->getMyOrder() === $this) {
  260.                 $historiquePaiement->setMyOrder(null);
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265. }