src/Entity/Message.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MessageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Runroom\SortableBehaviorBundle\Behaviors\Sortable;
  10. #[ORM\Entity(repositoryClassMessageRepository::class)]
  11. class Message
  12. {
  13.     use Sortable;
  14.     use TimestampableEntity;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length1000)]
  20.     private ?string $title null;
  21.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  22.     private ?string $body null;
  23.     #[ORM\ManyToMany(targetEntityTitle::class, inversedBy'messages')]
  24.     private Collection $titles;
  25.     #[ORM\Column]
  26.     private bool $isStarred false;
  27.     #[ORM\Column]
  28.     private ?bool $isActive null;
  29.     public function __construct()
  30.     {
  31.         $this->titles = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getTitle(): ?string
  38.     {
  39.         return $this->title;
  40.     }
  41.     public function setTitle(string $title): static
  42.     {
  43.         $this->title $title;
  44.         return $this;
  45.     }
  46.     public function getBody(): ?string
  47.     {
  48.         return $this->body;
  49.     }
  50.     public function setBody(?string $body): static
  51.     {
  52.         $this->body $body;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection<int, Title>
  57.      */
  58.     public function getTitles(): Collection
  59.     {
  60.         return $this->titles;
  61.     }
  62.     public function addTitle(Title $title): static
  63.     {
  64.         if (!$this->titles->contains($title)) {
  65.             $this->titles->add($title);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeTitle(Title $title): static
  70.     {
  71.         $this->titles->removeElement($title);
  72.         return $this;
  73.     }
  74.     public function isIsStarred(): bool
  75.     {
  76.         return $this->isStarred;
  77.     }
  78.     public function setIsStarred(bool $isStarred): static
  79.     {
  80.         $this->isStarred $isStarred;
  81.         return $this;
  82.     }
  83.     public function isIsActive(): ?bool
  84.     {
  85.         return $this->isActive;
  86.     }
  87.     public function setIsActive(bool $isActive): static
  88.     {
  89.         $this->isActive $isActive;
  90.         return $this;
  91.     }
  92.     // add to string
  93.     public function __toString()
  94.     {
  95.         return (string)$this->title;
  96.     }
  97. }