src/Entity/Invitation.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InvitationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassInvitationRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. class Invitation
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length255)]
  16.     private $email;
  17.     #[ORM\ManyToMany(targetEntityWorkroom::class, inversedBy'invitations')]
  18.     private $workroom;
  19.     #[ORM\Column(type'datetime_immutable')]
  20.     private $created_at;
  21.     public function __construct()
  22.     {
  23.         $this->workroom = new ArrayCollection();
  24.     }
  25.     /**
  26.      * Gets triggered only on insert.
  27.      * Set created date.
  28.      */
  29.     #[ORM\PrePersist]
  30.     public function onPrePersist()
  31.     {
  32.         $this->setCreatedAt(new \DateTimeImmutable());
  33.         return $this;
  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.     /**
  49.      * @return Collection|Workroom[]
  50.      */
  51.     public function getWorkroom(): Collection
  52.     {
  53.         return $this->workroom;
  54.     }
  55.     public function addWorkroom(Workroom $workroom): self
  56.     {
  57.         if (!$this->workroom->contains($workroom)) {
  58.             $this->workroom[] = $workroom;
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeWorkroom(Workroom $workroom): self
  63.     {
  64.         $this->workroom->removeElement($workroom);
  65.         return $this;
  66.     }
  67.     public function getCreatedAt(): ?\DateTimeImmutable
  68.     {
  69.         return $this->created_at;
  70.     }
  71.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  72.     {
  73.         $this->created_at $created_at;
  74.         return $this;
  75.     }
  76. }