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.     public function __construct()
  48.     {   
  49.         $this->commandeDetails = new ArrayCollection();
  50.         // <// Définir l'état initial
  51.         $this->setWorkflowState('created');
  52.     }
  53.     
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getDateCmd(): ?\DateTimeInterface
  59.     {
  60.         return $this->date_cmd;
  61.     }
  62.     public function setDateCmd(\DateTimeInterface $date_cmd): self
  63.     {
  64.         $this->date_cmd $date_cmd;
  65.         return $this;
  66.     }
  67.     public function getNumeroCmd(): ?string
  68.     {
  69.         return $this->numero_cmd;
  70.     }
  71.     public function setNumeroCmd(string $numero_cmd): self
  72.     {
  73.         $this->numero_cmd $numero_cmd;
  74.         return $this;
  75.     }
  76.     public function getPrixTotal(): ?float
  77.     {
  78.         return $this->prix_total;
  79.     }
  80.     public function setPrixTotal(float $prix_total): self
  81.     {
  82.         $this->prix_total $prix_total;
  83.         return $this;
  84.     }
  85.     public function getStatusCmd(): ?string
  86.     {
  87.         return $this->status_cmd;
  88.     }
  89.     public function setStatusCmd(string $status_cmd): self
  90.     {
  91.         $this->status_cmd $status_cmd;
  92.         return $this;
  93.     }
  94.     public function getRecapCmd(): array
  95.     {
  96.         return $this->recap_cmd;
  97.     }
  98.     public function setRecapCmd(array $recap_cmd): self
  99.     {
  100.         $this->recap_cmd $recap_cmd;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, CommandeDetails>
  105.      */
  106.     public function getCommandeDetails(): Collection
  107.     {
  108.         return $this->commandeDetails;
  109.     }
  110.     public function addCommandeDetail(CommandeDetails $commandeDetail): self
  111.     {
  112.         if (!$this->commandeDetails->contains($commandeDetail)) {
  113.             $this->commandeDetails->add($commandeDetail);
  114.             $commandeDetail->setCommande($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeCommandeDetail(CommandeDetails $commandeDetail): self
  119.     {
  120.         if ($this->commandeDetails->removeElement($commandeDetail)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($commandeDetail->getCommande() === $this) {
  123.                 $commandeDetail->setCommande(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getUser(): ?User
  129.     {
  130.         return $this->user;
  131.     }
  132.     public function setUser(?User $user): self
  133.     {
  134.         $this->user $user;
  135.         return $this;
  136.     }
  137.     public function getNom(): ?string
  138.     {
  139.         return $this->nom;
  140.     }
  141.     public function setNom(string $nom): self
  142.     {
  143.         $this->nom $nom;
  144.         return $this;
  145.     }
  146.     public function getPrenom(): ?string
  147.     {
  148.         return $this->prenom;
  149.     }
  150.     public function setPrenom(string $prenom): self
  151.     {
  152.         $this->prenom $prenom;
  153.         return $this;
  154.     }
  155.     public function getAddresse(): ?Addresse
  156.     {
  157.         return $this->addresse;
  158.     }
  159.     public function setAddresse(?Addresse $addresse): self
  160.     {
  161.         $this->addresse $addresse;
  162.         return $this;
  163.     }
  164.     public function getCmdStatus(): ?CommandeStatus
  165.     {
  166.         return $this->cmdStatus;
  167.     }
  168.     public function setCmdStatus(?CommandeStatus $cmdStatus): self
  169.     {
  170.         $this->cmdStatus $cmdStatus;
  171.         return $this;
  172.     }
  173.     public function getFraisLivraison(): ?float
  174.     {
  175.         return $this->frais_livraison;
  176.     }
  177.     public function setFraisLivraison(?float $frais_livraison): self
  178.     {
  179.         $this->frais_livraison $frais_livraison;
  180.         return $this;
  181.     }
  182.     public function getWorkflowState(): string
  183.     {
  184.         return $this->workflowState;
  185.     }
  186.     public function setWorkflowState(string $workflowState): void
  187.     {
  188.         $this->workflowState $workflowState;
  189.     }
  190.     public function getFacture(): ?Facture
  191.     {
  192.         return $this->facture;
  193.     }
  194.     public function setFacture(?Facture $facture): self
  195.     {
  196.         $this->facture $facture;
  197.         return $this;
  198.     }
  199. }