src/Entity/Invitation.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Kimia;
  4. use App\Repository\InvitationRepository;
  5. use DateTimeImmutable;
  6. use DateTimeInterface;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassInvitationRepository::class)]
  10. class Invitation
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180)]
  17.     private ?string $email null;
  18.     #[ORM\Column(typeTypes::TEXT)]
  19.     private ?string $message null;
  20.     #[ORM\Column(length14)]
  21.     private ?string $code;
  22.     #[ORM\Column(length1options: ["default" => Kimia::STATUS_INVITED])]
  23.     private ?int $status;
  24.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  25.     private ?DateTimeInterface $sentAt null;
  26.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  27.     private ?DateTimeImmutable $expiresAt null;
  28.     #[ORM\ManyToOne(inversedBy'invitations')]
  29.     private ?Establishment $establishment null;
  30.     public function __construct()
  31.     {
  32.         $this->code substr(uniqid(), -14);
  33.         $this->status Kimia::STATUS_INVITED;
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getEmail(): ?string
  40.     {
  41.         return $this->email;
  42.     }
  43.     public function setEmail(string $email): self
  44.     {
  45.         $this->email $email;
  46.         return $this;
  47.     }
  48.     public function getMessage(): ?string
  49.     {
  50.         return $this->message;
  51.     }
  52.     public function setMessage(string $message): self
  53.     {
  54.         $this->message $message;
  55.         return $this;
  56.     }
  57.     public function getCode(): ?string
  58.     {
  59.         return $this->code;
  60.     }
  61.     public function setCode(string $code): self
  62.     {
  63.         $this->code $code;
  64.         return $this;
  65.     }
  66.     public function getStatus(): ?int
  67.     {
  68.         return $this->status;
  69.     }
  70.     public function getStatusView(): ?string
  71.     {
  72.         $status $this->getStatus() === Kimia::STATUS_ACCEPTED 'success' : ($this->getStatus() === Kimia::STATUS_INVITED 'warning' 'danger');
  73.         $text $this->getStatus() === Kimia::STATUS_ACCEPTED 'Acceptée' : ($this->getStatus() === Kimia::STATUS_INVITED 'Invitée' : ($this->getStatus() === Kimia::STATUS_DECLINED 'Rejetée' : ($this->getStatus() === Kimia::STATUS_CANCEL 'Annulée' 'Echec')));
  74.         return "<span class='badge badge-soft-{$status}'>$text</span>";
  75.     }
  76.     public function setStatus(int $status): self
  77.     {
  78.         $this->status $status;
  79.         return $this;
  80.     }
  81.     public function getSentAt(): ?DateTimeInterface
  82.     {
  83.         return $this->sentAt;
  84.     }
  85.     public function setSentAt(DateTimeInterface $sentAt): self
  86.     {
  87.         $this->sentAt $sentAt;
  88.         return $this;
  89.     }
  90.     public function getExpiresAt(): ?DateTimeImmutable
  91.     {
  92.         return $this->expiresAt;
  93.     }
  94.     public function setExpiresAt(DateTimeImmutable $expiresAt): self
  95.     {
  96.         $this->expiresAt $expiresAt;
  97.         return $this;
  98.     }
  99.     public function getEstablishment(): ?Establishment
  100.     {
  101.         return $this->establishment;
  102.     }
  103.     public function setEstablishment(?Establishment $establishment): self
  104.     {
  105.         $this->establishment $establishment;
  106.         return $this;
  107.     }
  108. }