<?php
namespace App\Entity;
use App\Repository\InvitationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InvitationRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Invitation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $email;
#[ORM\ManyToMany(targetEntity: Workroom::class, inversedBy: 'invitations')]
private $workroom;
#[ORM\Column(type: 'datetime_immutable')]
private $created_at;
public function __construct()
{
$this->workroom = new ArrayCollection();
}
/**
* Gets triggered only on insert.
* Set created date.
*/
#[ORM\PrePersist]
public function onPrePersist()
{
$this->setCreatedAt(new \DateTimeImmutable());
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* @return Collection|Workroom[]
*/
public function getWorkroom(): Collection
{
return $this->workroom;
}
public function addWorkroom(Workroom $workroom): self
{
if (!$this->workroom->contains($workroom)) {
$this->workroom[] = $workroom;
}
return $this;
}
public function removeWorkroom(Workroom $workroom): self
{
$this->workroom->removeElement($workroom);
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
}