src/Entity/Commande.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\CommandeStatus;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Repository\CommandeRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. #[ORM\Entity(repositoryClassCommandeRepository::class)]
  10. class Commande
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  17.     private ?\DateTimeInterface $date_cmd null;
  18.     #[ORM\Column(length30)]
  19.     private ?string $numero_cmd null;
  20.     #[ORM\Column]
  21.     private ?float $prix_total null;
  22.     #[ORM\Column(length30)]
  23.     private ?string $status_cmd null;
  24.     
  25.     #[ORM\Column(length255)]
  26.     private $workflowState;
  27.     
  28.     
  29.     #[ORM\Column(typeTypes::JSON)]
  30.     private array $recap_cmd = [];
  31.     #[ORM\OneToMany(mappedBy'commande'targetEntityCommandeDetails::class, orphanRemovaltrue)]
  32.     private Collection $commandeDetails;
  33.     #[ORM\ManyToOne(inversedBy'commandes')]
  34.     private ?User $user null;
  35.     #[ORM\Column(length100)]
  36.     private ?string $nom null;
  37.     #[ORM\Column(length100)]
  38.     private ?string $prenom null;
  39.     #[ORM\ManyToOne]
  40.     private ?Addresse $addresse null;
  41.     #[ORM\ManyToOne(inversedBy'commandes')]
  42.     private ?CommandeStatus $cmdStatus null;
  43.     #[ORM\Column(nullabletrue)]
  44.     private ?float $frais_livraison null;
  45.     #[ORM\OneToOne(inversedBy'commande'cascade: ['persist''remove'])]
  46.     private ?Facture $facture null;
  47.     // ── Driver assigned at "Out for Delivery" (the actual collector for this order) ──
  48.     #[ORM\Column(length120nullabletrue)]
  49.     private ?string $driver_name null;
  50.     #[ORM\Column(length40nullabletrue)]
  51.     private ?string $driver_phone null;
  52.     public function __construct()
  53.     {   
  54.         $this->commandeDetails = new ArrayCollection();
  55.         // <// Définir l'état initial
  56.         $this->setWorkflowState('created');
  57.     }
  58.     
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getDateCmd(): ?\DateTimeInterface
  64.     {
  65.         return $this->date_cmd;
  66.     }
  67.     public function setDateCmd(\DateTimeInterface $date_cmd): self
  68.     {
  69.         $this->date_cmd $date_cmd;
  70.         return $this;
  71.     }
  72.     public function getNumeroCmd(): ?string
  73.     {
  74.         return $this->numero_cmd;
  75.     }
  76.     public function setNumeroCmd(string $numero_cmd): self
  77.     {
  78.         $this->numero_cmd $numero_cmd;
  79.         return $this;
  80.     }
  81.     public function getPrixTotal(): ?float
  82.     {
  83.         return $this->prix_total;
  84.     }
  85.     public function setPrixTotal(float $prix_total): self
  86.     {
  87.         $this->prix_total $prix_total;
  88.         return $this;
  89.     }
  90.     public function getStatusCmd(): ?string
  91.     {
  92.         return $this->status_cmd;
  93.     }
  94.     public function setStatusCmd(string $status_cmd): self
  95.     {
  96.         $this->status_cmd $status_cmd;
  97.         return $this;
  98.     }
  99.     public function getRecapCmd(): array
  100.     {
  101.         return $this->recap_cmd;
  102.     }
  103.     public function setRecapCmd(array $recap_cmd): self
  104.     {
  105.         $this->recap_cmd $recap_cmd;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection<int, CommandeDetails>
  110.      */
  111.     public function getCommandeDetails(): Collection
  112.     {
  113.         return $this->commandeDetails;
  114.     }
  115.     public function addCommandeDetail(CommandeDetails $commandeDetail): self
  116.     {
  117.         if (!$this->commandeDetails->contains($commandeDetail)) {
  118.             $this->commandeDetails->add($commandeDetail);
  119.             $commandeDetail->setCommande($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeCommandeDetail(CommandeDetails $commandeDetail): self
  124.     {
  125.         if ($this->commandeDetails->removeElement($commandeDetail)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($commandeDetail->getCommande() === $this) {
  128.                 $commandeDetail->setCommande(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     public function getUser(): ?User
  134.     {
  135.         return $this->user;
  136.     }
  137.     public function setUser(?User $user): self
  138.     {
  139.         $this->user $user;
  140.         return $this;
  141.     }
  142.     public function getNom(): ?string
  143.     {
  144.         return $this->nom;
  145.     }
  146.     public function setNom(string $nom): self
  147.     {
  148.         $this->nom $nom;
  149.         return $this;
  150.     }
  151.     public function getPrenom(): ?string
  152.     {
  153.         return $this->prenom;
  154.     }
  155.     public function setPrenom(string $prenom): self
  156.     {
  157.         $this->prenom $prenom;
  158.         return $this;
  159.     }
  160.     public function getAddresse(): ?Addresse
  161.     {
  162.         return $this->addresse;
  163.     }
  164.     public function setAddresse(?Addresse $addresse): self
  165.     {
  166.         $this->addresse $addresse;
  167.         return $this;
  168.     }
  169.     public function getCmdStatus(): ?CommandeStatus
  170.     {
  171.         return $this->cmdStatus;
  172.     }
  173.     public function setCmdStatus(?CommandeStatus $cmdStatus): self
  174.     {
  175.         $this->cmdStatus $cmdStatus;
  176.         return $this;
  177.     }
  178.     public function getFraisLivraison(): ?float
  179.     {
  180.         return $this->frais_livraison;
  181.     }
  182.     public function setFraisLivraison(?float $frais_livraison): self
  183.     {
  184.         $this->frais_livraison $frais_livraison;
  185.         return $this;
  186.     }
  187.     public function getWorkflowState(): string
  188.     {
  189.         return $this->workflowState;
  190.     }
  191.     public function setWorkflowState(string $workflowState): void
  192.     {
  193.         $this->workflowState $workflowState;
  194.     }
  195.     public function getFacture(): ?Facture
  196.     {
  197.         return $this->facture;
  198.     }
  199.     public function setFacture(?Facture $facture): self
  200.     {
  201.         $this->facture $facture;
  202.         return $this;
  203.     }
  204.     public function getDriverName(): ?string
  205.     {
  206.         return $this->driver_name;
  207.     }
  208.     public function setDriverName(?string $driver_name): self
  209.     {
  210.         $this->driver_name $driver_name;
  211.         return $this;
  212.     }
  213.     public function getDriverPhone(): ?string
  214.     {
  215.         return $this->driver_phone;
  216.     }
  217.     public function setDriverPhone(?string $driver_phone): self
  218.     {
  219.         $this->driver_phone $driver_phone;
  220.         return $this;
  221.     }
  222. }