src/Entity/Order.php line 15

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. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  10.  * @ORM\Table(name="`order`")
  11.  */
  12. class Order
  13. {
  14.     const status = [
  15.         'Annuler'=>'Annuler',
  16.         'En attente'=>'En attente',
  17.         'En cour'=>'En cour',
  18.         'Livraison'=>'Livraison',
  19.         'Terminer'=>'Terminer'
  20.     ];
  21.     const EN_COUR 'En cour';
  22.     const EN_ATTENTE 'En attente';
  23.     const TERMINER ='Terminer';
  24.     const LIVRAISON 'Livraison';
  25.     const ANNULER ='Annuler';
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $number;
  36.     /**
  37.      * @ORM\Column(type="text", nullable=true)
  38.      */
  39.     private $note;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      */
  43.     private $state;
  44.     /**
  45.      * @ORM\Column(type="datetime", nullable=true)
  46.      */
  47.     private $checkout_completed_at;
  48.     /**
  49.      * @ORM\Column(type="integer")
  50.      */
  51.     private $total;
  52.     /**
  53.      * @ORM\Column(type="datetime")
  54.      */
  55.     private $created_at;
  56.     /**
  57.      * @ORM\Column(type="datetime", nullable=true)
  58.      */
  59.     private $updated_at;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=OrderItem::class, mappedBy="commande", orphanRemoval=true, cascade={"persist"})
  62.      */
  63.     private $order_item;
  64.     /**
  65.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="orders")
  66.      * @ORM\JoinColumn(nullable=false)
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\Column(type="datetime")
  71.      */
  72.     private $paymentDue;
  73.     /**
  74.      * @ORM\OneToOne(targetEntity=Payment::class, inversedBy="order_payment", cascade={"persist", "remove"})
  75.      */
  76.     private $payment;
  77.     /**
  78.      * @ORM\Column(type="integer")
  79.      */
  80.     private $items_total;
  81.     /**
  82.      * @ORM\Column(type="integer")
  83.      */
  84.     private $adjustments_total;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=DeliverySpace::class, inversedBy="orders", cascade={"persist"})
  87.      */
  88.     private $delivery_space;
  89.     /**
  90.      * @ORM\Column(type="boolean" ,options={"default"="1"})
  91.      */
  92.     private $is_immuable;
  93.     private $street;
  94.     /**
  95.      * @ORM\Column(type="integer", nullable=true)
  96.      */
  97.     private $shipping;
  98.     /**
  99.      * @ORM\Column(type="string", length=255)
  100.      */
  101.     private $shipping_state;
  102.     /**
  103.      * @ORM\Column(type="string", length=255)
  104.      */
  105.     private $method_payment;
  106.     public function __construct()
  107.     {
  108.         $this->order_item = new ArrayCollection();
  109.         $this->created_at = new \DateTime();
  110.         $this->is_immuable true;
  111.     }
  112.     public function getFacture(){
  113.         return 'Facture N° '.$this->getNumber().' - Lest';
  114.     }
  115.     public function getId(): ?int
  116.     {
  117.         return $this->id;
  118.     }
  119.     public function getNumber(): ?string
  120.     {
  121.         return $this->number;
  122.     }
  123.     public function setNumber(string $number): self
  124.     {
  125.         $this->number $number;
  126.         // sprintf("%06s", 1);
  127.         return $this;
  128.     }
  129.     public function getNote(): ?string
  130.     {
  131.         return $this->note;
  132.     }
  133.     public function setNote(?string $note): self
  134.     {
  135.         $this->note $note;
  136.         return $this;
  137.     }
  138.     public function getState(): ?string
  139.     {
  140.         return $this->state;
  141.     }
  142.     public function setState(string $state): self
  143.     {
  144.         $this->state $state;
  145.         return $this;
  146.     }
  147.     public function getCheckoutCompletedAt(): ?\DateTimeInterface
  148.     {
  149.         return $this->checkout_completed_at;
  150.     }
  151.     public function setCheckoutCompletedAt(?\DateTimeInterface $checkout_completed_at): self
  152.     {
  153.         $this->checkout_completed_at $checkout_completed_at;
  154.         return $this;
  155.     }
  156.     public function getTotal(): ?int
  157.     {
  158.         return $this->total;
  159.     }
  160.     public function formatterTotal()
  161.     {
  162.         return number_format($this->total,0,'',' ');
  163.     }
  164.     public function setTotal(int $total): self
  165.     {
  166.         $this->total $total;
  167.         return $this;
  168.     }
  169.     public function getCreatedAt(): ?\DateTimeInterface
  170.     {
  171.         return $this->created_at;
  172.     }
  173.     public function setCreatedAt(\DateTimeInterface $created_at): self
  174.     {
  175.         $this->created_at $created_at;
  176.         return $this;
  177.     }
  178.     public function getUpdatedAt(): ?\DateTimeInterface
  179.     {
  180.         return $this->updated_at;
  181.     }
  182.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  183.     {
  184.         $this->updated_at $updated_at;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection|OrderItem[]
  189.      */
  190.     public function getOrderItem(): Collection
  191.     {
  192.         return $this->order_item;
  193.     }
  194.     public function addOrderItem(OrderItem $orderItem): self
  195.     {
  196.         if (!$this->order_item->contains($orderItem)) {
  197.             $this->order_item[] = $orderItem;
  198.             $orderItem->setCommande($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removeOrderItem(OrderItem $orderItem): self
  203.     {
  204.         if ($this->order_item->removeElement($orderItem)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($orderItem->getCommande() === $this) {
  207.                 $orderItem->setCommande(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     public function getUser(): ?User
  213.     {
  214.         return $this->user;
  215.     }
  216.     public function setUser(?User $user): self
  217.     {
  218.         $this->user $user;
  219.         return $this;
  220.     }
  221.     public function getPaymentDue(): ?\DateTimeInterface
  222.     {
  223.         return $this->paymentDue;
  224.     }
  225.     public function setPaymentDue(\DateTimeInterface $paymentDue): self
  226.     {
  227.         $this->paymentDue $paymentDue;
  228.         return $this;
  229.     }
  230.     public function getPayment(): ?Payment
  231.     {
  232.         return $this->payment;
  233.     }
  234.     public function setPayment(?Payment $payment): self
  235.     {
  236.         $this->payment $payment;
  237.         return $this;
  238.     }
  239.     public function getItemsTotal(): ?int
  240.     {
  241.         return $this->items_total;
  242.     }
  243.     public function setItemsTotal(int $items_total): self
  244.     {
  245.         $this->items_total $items_total;
  246.         return $this;
  247.     }
  248.     public function getAdjustmentsTotal(): ?int
  249.     {
  250.         return $this->adjustments_total;
  251.     }
  252.     public function setAdjustmentsTotal($adjustments_total): self
  253.     {
  254.         $this->adjustments_total =(int) $adjustments_total;
  255.         return $this;
  256.     }
  257.     public function getDeliverySpace(): ?DeliverySpace
  258.     {
  259.         return $this->delivery_space;
  260.     }
  261.     public function setDeliverySpace(?DeliverySpace $delivery_space): self
  262.     {
  263.         $this->delivery_space $delivery_space;
  264.         return $this;
  265.     }
  266.     public function getIsImmuable(): ?bool
  267.     {
  268.         return $this->is_immuable;
  269.     }
  270.     public function setIsImmuable(bool $is_immuable): self
  271.     {
  272.         $this->is_immuable $is_immuable;
  273.         return $this;
  274.     }
  275.     public function getStreet() : ?Street
  276.     {
  277.         return $this->street;
  278.     }
  279.     public function setStreet($street): self
  280.     {
  281.         $this->street $street;
  282.         return $this;
  283.     }
  284.     public function getShipping(): ?int
  285.     {
  286.         return $this->shipping;
  287.     }
  288.     public function setShipping(?int $shipping): self
  289.     {
  290.         $this->shipping $shipping;
  291.         return $this;
  292.     }
  293.     public function getShippingState(): ?string
  294.     {
  295.         return $this->shipping_state;
  296.     }
  297.     public function setShippingState(string $shipping_state): self
  298.     {
  299.         $this->shipping_state $shipping_state;
  300.         return $this;
  301.     }
  302.     public function getMethodPayment(): ?string
  303.     {
  304.         return $this->method_payment;
  305.     }
  306.     public function setMethodPayment(string $method_payment): self
  307.     {
  308.         $this->method_payment $method_payment;
  309.         return $this;
  310.     }
  311. }