src/Entity/DeclarationConducteur.php line 22

Open in your IDE?
  1. <?php
  2. // src/Entity/DeclarationConducteur.php
  3. namespace App\Entity;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(
  10.  *     name="declaration_conducteur",
  11.  *     indexes={
  12.  *         @ORM\Index(name="idx_immat", columns={"immatriculation"}),
  13.  *         @ORM\Index(name="idx_client", columns={"nom_client"}),
  14.  *         @ORM\Index(name="idx_periode", columns={"date_debut", "date_fin"}),
  15.  *         @ORM\Index(name="idx_status", columns={"status"})
  16.  *     }
  17.  * )
  18.  */
  19. class DeclarationConducteur
  20. {
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private ?int $id null;
  27.     /**
  28.      * @ORM\OneToOne(targetEntity=UploadBatch::class, inversedBy="declaration")
  29.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  30.      */
  31.     private ?UploadBatch $uploadBatch null;
  32.     // ───── En-tête ─────
  33.     /** @ORM\Column(type="string", length=150, nullable=true) */
  34.     private ?string $agence null;
  35.     /** @ORM\Column(type="string", length=50, nullable=true) */
  36.     private ?string $immatriculation null;
  37.     /** @ORM\Column(type="string", length=100, nullable=true) */
  38.     private ?string $numero_licence null;
  39.     /** @ORM\Column(type="string", length=150, nullable=true) */
  40.     private ?string $nom_client null;
  41.     /** @ORM\Column(type="date", nullable=true) */
  42.     private ?\DateTimeInterface $date_debut null;
  43.     /** @ORM\Column(type="date", nullable=true) */
  44.     private ?\DateTimeInterface $date_fin null;
  45.     /** @ORM\Column(type="string", length=20, options={"default":"pending"}) */
  46.     private string $status 'pending';
  47.     // ───── Dates automatiques ─────
  48.     /**
  49.      * @ORM\Column(type="datetime_immutable")
  50.      */
  51.     private \DateTimeImmutable $createdAt;
  52.     /**
  53.      * @ORM\Column(type="datetime_immutable", nullable=true)
  54.      */
  55.     private ?\DateTimeImmutable $processedAt null;
  56.     // ───── Lignes ─────
  57.     /**
  58.      * @ORM\OneToMany(
  59.      *     targetEntity=DeclarationLigne::class,
  60.      *     mappedBy="declaration",
  61.      *     cascade={"persist", "remove"},
  62.      *     orphanRemoval=true
  63.      * )
  64.      */
  65.     private Collection $lignes;
  66.     public function __construct()
  67.     {
  68.         $this->createdAt = new \DateTimeImmutable();
  69.         $this->lignes = new ArrayCollection();
  70.     }
  71.     // ───── Getters & Setters ─────
  72.     public function getId(): ?int { return $this->id; }
  73.     public function getUploadBatch(): ?UploadBatch { return $this->uploadBatch; }
  74.     public function setUploadBatch(?UploadBatch $uploadBatch): self $this->uploadBatch $uploadBatch; return $this; }
  75.     public function getAgence(): ?string { return $this->agence; }
  76.     public function setAgence(?string $agence): self $this->agence $agence; return $this; }
  77.     public function getImmatriculation(): ?string { return $this->immatriculation; }
  78.     public function setImmatriculation(?string $immatriculation): self $this->immatriculation $immatriculation; return $this; }
  79.     public function getNumeroLicence(): ?string { return $this->numero_licence; }
  80.     public function setNumeroLicence(?string $numero_licence): self $this->numero_licence $numero_licence; return $this; }
  81.     public function getNomClient(): ?string { return $this->nom_client; }
  82.     public function setNomClient(?string $nom_client): self $this->nom_client $nom_client; return $this; }
  83.     public function getDateDebut(): ?\DateTimeInterface { return $this->date_debut; }
  84.     public function setDateDebut(?\DateTimeInterface $date_debut): self $this->date_debut $date_debut; return $this; }
  85.     public function getDateFin(): ?\DateTimeInterface { return $this->date_fin; }
  86.     public function setDateFin(?\DateTimeInterface $date_fin): self $this->date_fin $date_fin; return $this; }
  87.     public function getStatus(): string { return $this->status; }
  88.     public function setStatus(string $status): self $this->status $status; return $this; }
  89.     public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; }
  90.     // PAS DE setCreatedAt() → c’est immuable, fixé dans le constructeur
  91.     public function getProcessedAt(): ?\DateTimeImmutable { return $this->processedAt; }
  92.     public function setProcessedAt(?\DateTimeImmutable $processedAt): self $this->processedAt $processedAt; return $this; }
  93.     public function getLignes(): Collection { return $this->lignes; }
  94.     public function addLigne(DeclarationLigne $ligne): self
  95.     {
  96.         if (!$this->lignes->contains($ligne)) {
  97.             $this->lignes[] = $ligne;
  98.             $ligne->setDeclaration($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeLigne(DeclarationLigne $ligne): self
  103.     {
  104.         $this->lignes->removeElement($ligne);
  105.         return $this;
  106.     }
  107. }