<?php
namespace App\Entity\ConversationMessage;
use App\Entity\User;
use App\Entity\UserUploadedFile;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Entity\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity()
*
* @ORM\Table(
* name="conversation_message_attachment_files",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="file_name_unique_idx", columns={"file_name"})
* },
* indexes={
*
* @ORM\Index(name="batch_id_idx", columns={"batch_id"}),
* }
* )
*
* @Vich\Uploadable
*/
class ConversationMessageAttachmentFile extends UserUploadedFile
{
/**
* @var string
*
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
*
* @ORM\Column(name="id", type="guid")
*
* @ORM\Id
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="conversationMessageAttachmentFiles", cascade={"persist"})
*
* @ORM\JoinColumn(name="users_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
protected User $user;
/**
* @var File|null
*
* @Vich\UploadableField(mapping="conversation_message_attachment_file", fileNameProperty="fileName")
*/
protected $file;
/**
* @var string
*
* @ORM\Column(name="file_name", type="string", length=255, nullable=false)
*/
protected $fileName;
/**
* @var string
*
* @ORM\Column(name="original_file_name", type="string", length=255, nullable=false)
*/
protected $originalFileName;
public function getOriginalFileName(): string
{
return $this->originalFileName;
}
/**
* @var string
*
* @ORM\Column(name="mime_type", type="string", length=255, nullable=false)
*/
protected $mimeType;
/**
* @var string
*
* @ORM\Column(name="batch_id", type="string", length=64, nullable=false)
*/
protected $batchId;
/**
* @var DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
protected $updatedAt;
/**
* At the beginning of a conversationMessageAttachmentFile lifecycle, it is not yet attached to any
* conversation message. That's because the attachment file is uploaded by the user while the user
* writes a new conversation message, which is only created once the conversation message form is submitted.
* Thus, this collection can be empty, and once one or more conversationMessage entities exist, these are assigned.
*
* It's a many-to-many relationship because multiple conversation messages can have the same attachment file, e.g.
* when a user writes to many receivers at once, and also, one conversation message can have 0-n attachment files.
*
* @var ConversationMessage[]|Collection|array
*
* @ORM\ManyToMany(targetEntity="App\Entity\ConversationMessage\ConversationMessage", inversedBy="conversationMessageAttachmentFiles", cascade={"persist"})
*
* @ORM\JoinColumn(name="conversation_messages_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*
* @ORM\JoinTable(
* name="conversation_messages_conversation_message_attachment_files",
* joinColumns={
*
* @ORM\JoinColumn(name="conversation_message_attachment_files_id", referencedColumnName="id", onDelete="CASCADE")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="conversation_messages_id", referencedColumnName="id", onDelete="CASCADE")
* }
* )
*/
protected $conversationMessages;
public function setConversationMessages(Collection $conversationMessages): void
{
$this->conversationMessages = $conversationMessages;
}
public function getConversationMessages(): Collection
{
return $this->conversationMessages;
}
}