src/Entity/SharedEventCodeUsage.php line 19

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Entity\Customer\Customer;
  5. use App\Repository\SharedEventCodeUsageRepository;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Trace un email (client) ayant utilisé un code événement partagé (rattachement API ou commande).
  10.  */
  11. #[ORM\Entity(repositoryClassSharedEventCodeUsageRepository::class)]
  12. #[ORM\Table(name'app_shared_event_code_usage')]
  13. #[ORM\UniqueConstraint(name'uniq_shared_event_code_email'columns: ['shared_event_code_id''email'])]
  14. #[ORM\Index(name'idx_shared_event_code_id'columns: ['shared_event_code_id'])]
  15. class SharedEventCodeUsage
  16. {
  17.     public const SOURCE_ATTACH 'attach';
  18.     public const SOURCE_ORDER 'order';
  19.     /** GET use-code réussi sans compte (ou avant connexion) — traçage BO « Anonyme ». */
  20.     public const SOURCE_USE_CODE 'use_code';
  21.     /** Préfixe stocké en colonne email pour les usages sans adresse connue (affichage BO : Anonyme). */
  22.     public const ANONYMOUS_EMAIL_PREFIX 'anon:';
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     private ?int $id null;
  27.     #[ORM\ManyToOne]
  28.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  29.     private ?SharedEventCode $sharedEventCode null;
  30.     /** Email normalisé (minuscules). */
  31.     #[ORM\Column(length255)]
  32.     private string $email '';
  33.     #[ORM\ManyToOne]
  34.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  35.     private ?Customer $customer null;
  36.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  37.     private ?\DateTimeImmutable $usedAt null;
  38.     /** attach = POST attach-shared-event ; order = commande avec code partagé */
  39.     #[ORM\Column(length20)]
  40.     private string $source self::SOURCE_ATTACH;
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getSharedEventCode(): ?SharedEventCode
  46.     {
  47.         return $this->sharedEventCode;
  48.     }
  49.     public function setSharedEventCode(?SharedEventCode $sharedEventCode): self
  50.     {
  51.         $this->sharedEventCode $sharedEventCode;
  52.         return $this;
  53.     }
  54.     public function getEmail(): string
  55.     {
  56.         return $this->email;
  57.     }
  58.     public function setEmail(string $email): self
  59.     {
  60.         $this->email $email;
  61.         return $this;
  62.     }
  63.     public function getCustomer(): ?Customer
  64.     {
  65.         return $this->customer;
  66.     }
  67.     public function setCustomer(?Customer $customer): self
  68.     {
  69.         $this->customer $customer;
  70.         return $this;
  71.     }
  72.     public function getUsedAt(): ?\DateTimeImmutable
  73.     {
  74.         return $this->usedAt;
  75.     }
  76.     public function setUsedAt(\DateTimeImmutable $usedAt): self
  77.     {
  78.         $this->usedAt $usedAt;
  79.         return $this;
  80.     }
  81.     public function getSource(): string
  82.     {
  83.         return $this->source;
  84.     }
  85.     public function setSource(string $source): self
  86.     {
  87.         $this->source $source;
  88.         return $this;
  89.     }
  90. }