<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
/**
* @ORM\HasLifecycleCallbacks()
*
* @ORM\Table("GuestbookEntry")
*
* @ORM\Entity(repositoryClass="App\Repository\GuestbookEntryRepository")
*/
class GuestbookEntry
{
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Id()
*
* @ORM\GeneratedValue()
*
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\ManyToOne(targetEntity="App\Entity\Member")
*
* @ORM\JoinColumn(name="sender_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
*/
private $sender;
/**
* @Groups({"adminindex", "guestbookindex", "timelineindex"})
*
* @ORM\ManyToOne(targetEntity="App\Entity\Member")
*
* @ORM\JoinColumn(name="recipient_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
*/
private $recipient;
/**
* @Groups({"adminindex", "guestbookindex"})
*
* @ORM\Column(type="boolean", options={"default" = 0})
*/
private $is_spam = false;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Column(type="boolean", options={"default" = 1})
*/
private $is_hidden = true;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Column(type="text")
*/
private $message;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @Groups({"guestbookindex", "timelineindex"})
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $commentedAt;
/**
* @ORM\PrePersist
*/
public function prePersistSetValues()
{
if (!$this->getCreatedAt()) {
$this->setCreatedAt(new \DateTime());
}
}
public function getId()
{
return $this->id;
}
public function getSender(): ?Member
{
return $this->sender;
}
public function setSender(Member $sender): self
{
$this->sender = $sender;
return $this;
}
public function getRecipient(): ?Member
{
return $this->recipient;
}
public function setRecipient(Member $recipient): self
{
$this->recipient = $recipient;
return $this;
}
public function getIsSpam(): ?bool
{
return $this->is_spam;
}
public function setIsSpam(bool $is_spam): self
{
$this->is_spam = $is_spam;
return $this;
}
public function getIsHidden(): ?bool
{
return $this->is_hidden;
}
public function setIsHidden(bool $is_hidden): self
{
$this->is_hidden = $is_hidden;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): self
{
$this->message = $message;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
if (null === $comment) {
$this->commentedAt = null;
}
if (null !== $comment && null === $this->commentedAt) {
$this->commentedAt = new \DateTime();
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCommentedAt(): ?\DateTimeInterface
{
return $this->commentedAt;
}
public function setCommentedAt(?\DateTimeInterface $commentedAt): self
{
$this->commentedAt = $commentedAt;
return $this;
}
}