<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ContactNoteRepository")
*/
class ContactNote
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Contact", inversedBy="contactNotes")
* @ORM\JoinColumn(nullable=true)
*/
private $contact;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="contactNotes")
* @ORM\JoinColumn(nullable=true)
*/
private $author;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $modified_at;
public function __construct ()
{
$this->description = "";
$this->created_at = new \DateTime("now");
$this->modified_at = new \DateTime("now");
}
public function getId()
{
return $this->id;
}
public function getContact(): ?contact
{
return $this->contact;
}
public function setContact(?contact $contact): self
{
$this->contact = $contact;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description = null): self
{
$this->description = $description ? $description : "";
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getModifiedAt(): ?\DateTimeInterface
{
return $this->modified_at;
}
public function setModifiedAt(\DateTimeInterface $modified_at): self
{
$this->modified_at = $modified_at;
return $this;
}
public function getByLine(): string
{
$text = '';
if ($date = $this->getCreatedAt()) {
$date = $date->format('F j, Y \a\t g:i a ');
$text .= "added on {$date}";
}
if ($author = $this->getAuthor()) {
$text .= "by " . $author->getDisplayname();
}
return $text;
}
}