<?php
namespace App\Entity;
use App\Repository\NotificationRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=NotificationRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Notification
{
const CATEGORY_APPOINTMENT_FEEDBACK = 'appt_fb';
const CATEGORY_APPOINTMENT_FEEDBACK_GLOBAL = 'appt_fb_all';
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=7)
*/
private $type;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $user;
/**
* @ORM\Column(type="text")
*/
private $message;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $closedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $scheduledAt;
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $category;
/**
* @ORM\Column(type="string", length=255)
*/
private $hash;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function isClosable(): bool
{
return !empty($this->user);
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): self
{
$this->message = $message;
return $this;
}
public function getClosedAt(): ?\DateTimeInterface
{
return $this->closedAt;
}
public function setClosedAt(?\DateTimeInterface $closedAt): self
{
$this->closedAt = $closedAt;
return $this;
}
public function markAsClosed(): self
{
return $this->setClosedAt(new \DateTime());
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getScheduledAt(): ?\DateTimeInterface
{
return $this->scheduledAt;
}
public function setScheduledAt(?\DateTimeInterface $scheduledAt): self
{
$this->scheduledAt = $scheduledAt;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getHash(): ?string
{
return $this->hash;
}
public function setHash(string $hash): self
{
$this->hash = $hash;
return $this;
}
/**
* @ORM\PrePersist
*/
public function computeHash()
{
$this->hash = md5($this->title . $this->message . $this->type);
return $this->hash;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
}