src/Entity/ContactNote.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\ContactNoteRepository")
  6.  */
  7. class ContactNote
  8. {
  9.     /**
  10.      * @ORM\Id()
  11.      * @ORM\GeneratedValue()
  12.      * @ORM\Column(type="integer")
  13.      */
  14.     private $id;
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity="App\Entity\Contact", inversedBy="contactNotes")
  17.      * @ORM\JoinColumn(nullable=true)
  18.      */
  19.     private $contact;
  20.     /**
  21.      * @ORM\Column(type="text")
  22.      */
  23.     private $description;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="contactNotes")
  26.      * @ORM\JoinColumn(nullable=true)
  27.      */
  28.     private $author;
  29.     
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $created_at;
  34.     
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private $modified_at;
  39.     
  40.     public function __construct ()
  41.     {
  42.         $this->description "";
  43.         $this->created_at = new \DateTime("now");
  44.         $this->modified_at = new \DateTime("now");
  45.     }
  46.     public function getId()
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getContact(): ?contact
  51.     {
  52.         return $this->contact;
  53.     }
  54.     public function setContact(?contact $contact): self
  55.     {
  56.         $this->contact $contact;
  57.         return $this;
  58.     }
  59.     public function getDescription(): ?string
  60.     {
  61.         return $this->description;
  62.     }
  63.     public function setDescription(string $description null): self
  64.     {
  65.         $this->description $description $description "";
  66.         return $this;
  67.     }
  68.     public function getAuthor(): ?User
  69.     {
  70.         return $this->author;
  71.     }
  72.     public function setAuthor(?User $author): self
  73.     {
  74.         $this->author $author;
  75.         
  76.         return $this;
  77.     }
  78.     
  79.     public function getCreatedAt(): ?\DateTimeInterface
  80.     {
  81.         return $this->created_at;
  82.     }
  83.     public function setCreatedAt(\DateTimeInterface $created_at): self
  84.     {
  85.         $this->created_at $created_at;
  86.         return $this;
  87.     }
  88.     
  89.     public function getModifiedAt(): ?\DateTimeInterface
  90.     {
  91.         return $this->modified_at;
  92.     }
  93.     public function setModifiedAt(\DateTimeInterface $modified_at): self
  94.     {
  95.         $this->modified_at $modified_at;
  96.         return $this;
  97.     }
  98.     
  99.     public function getByLine(): string
  100.     {
  101.         $text '';
  102.         if ($date $this->getCreatedAt()) {
  103.             $date $date->format('F j, Y \a\t g:i a ');
  104.             $text .= "added on {$date}";
  105.         }
  106.         if ($author $this->getAuthor()) {
  107.             $text .= "by " $author->getDisplayname();
  108.         }
  109.         
  110.         return $text;
  111.     }
  112.     
  113. }