160 lines
3.2 KiB
PHP
160 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity\System;
|
|
|
|
use App\Enums\System\MessageType;
|
|
use App\Repository\System\MessagesRepository;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
#[ORM\Entity(repositoryClass: MessagesRepository::class)]
|
|
class Messages
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
|
private ?Uuid $id = null;
|
|
|
|
#[ORM\Column]
|
|
private ?\DateTimeImmutable $sent = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?\DateTimeImmutable $received = null;
|
|
|
|
#[ORM\ManyToOne]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $recipient = null;
|
|
|
|
#[ORM\Column(enumType: MessageType::class)]
|
|
private ?MessageType $type = null;
|
|
|
|
#[ORM\Column(type: Types::TEXT)]
|
|
private ?string $message = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $title = null;
|
|
|
|
#[ORM\ManyToOne]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?User $sender = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $link = null;
|
|
|
|
public function getId(): ?Uuid
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getSent(): ?\DateTimeImmutable
|
|
{
|
|
return $this->sent;
|
|
}
|
|
|
|
public function setSent(\DateTimeImmutable $sent): static
|
|
{
|
|
$this->sent = $sent;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getReceived(): ?\DateTimeImmutable
|
|
{
|
|
return $this->received;
|
|
}
|
|
|
|
public function setReceived(?\DateTimeImmutable $received): static
|
|
{
|
|
$this->received = $received;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRecipient(): ?User
|
|
{
|
|
return $this->recipient;
|
|
}
|
|
|
|
public function setRecipient(?User $recipient): static
|
|
{
|
|
$this->recipient = $recipient;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getType(): ?MessageType
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function setType(MessageType $type): static
|
|
{
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMessage(): ?string
|
|
{
|
|
return $this->message;
|
|
}
|
|
|
|
public function setMessage(string $message): static
|
|
{
|
|
$this->message = $message;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setTitle(string $title): static
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSender(): ?User
|
|
{
|
|
return $this->sender;
|
|
}
|
|
|
|
public function setSender(?User $sender): static
|
|
{
|
|
$this->sender = $sender;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'id' => $this->id->toHex(),
|
|
'title' => $this->title,
|
|
'sender' => $this->sender->getName(),
|
|
'type' => $this->type->name,
|
|
'date' => $this->sent,
|
|
'message' => $this->message
|
|
];
|
|
}
|
|
|
|
public function getLink(): ?string
|
|
{
|
|
return $this->link;
|
|
}
|
|
|
|
public function setLink(?string $link): static
|
|
{
|
|
$this->link = $link;
|
|
|
|
return $this;
|
|
}
|
|
}
|