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.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     private ?int $id null;
  23.     #[ORM\ManyToOne]
  24.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  25.     private ?SharedEventCode $sharedEventCode null;
  26.     /** Email normalisé (minuscules). */
  27.     #[ORM\Column(length255)]
  28.     private string $email '';
  29.     #[ORM\ManyToOne]
  30.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  31.     private ?Customer $customer null;
  32.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  33.     private ?\DateTimeImmutable $usedAt null;
  34.     /** attach = POST attach-shared-event ; order = commande avec code partagé */
  35.     #[ORM\Column(length20)]
  36.     private string $source self::SOURCE_ATTACH;
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getSharedEventCode(): ?SharedEventCode
  42.     {
  43.         return $this->sharedEventCode;
  44.     }
  45.     public function setSharedEventCode(?SharedEventCode $sharedEventCode): self
  46.     {
  47.         $this->sharedEventCode $sharedEventCode;
  48.         return $this;
  49.     }
  50.     public function getEmail(): string
  51.     {
  52.         return $this->email;
  53.     }
  54.     public function setEmail(string $email): self
  55.     {
  56.         $this->email $email;
  57.         return $this;
  58.     }
  59.     public function getCustomer(): ?Customer
  60.     {
  61.         return $this->customer;
  62.     }
  63.     public function setCustomer(?Customer $customer): self
  64.     {
  65.         $this->customer $customer;
  66.         return $this;
  67.     }
  68.     public function getUsedAt(): ?\DateTimeImmutable
  69.     {
  70.         return $this->usedAt;
  71.     }
  72.     public function setUsedAt(\DateTimeImmutable $usedAt): self
  73.     {
  74.         $this->usedAt $usedAt;
  75.         return $this;
  76.     }
  77.     public function getSource(): string
  78.     {
  79.         return $this->source;
  80.     }
  81.     public function setSource(string $source): self
  82.     {
  83.         $this->source $source;
  84.         return $this;
  85.     }
  86. }