|
|
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|
|
namespace App\Entity\Message;
|
|
|
|
|
|
use App\Attribute\OrganizationDefaultValue;
|
|
|
+use App\Entity\Core\File;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Enum\Message\MessageStatusEnum;
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
@@ -55,8 +56,14 @@ abstract class AbstractMessage
|
|
|
#[ORM\Column(type: 'text', nullable: true)]
|
|
|
protected string $text;
|
|
|
|
|
|
-// #[ORM\OneToMany(mappedBy: 'message', targetEntity: ReportMessage::class, cascade: ['persist'], orphanRemoval: true)]
|
|
|
-// protected Collection $reportMessage;
|
|
|
+ #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
|
|
|
+ #[ORM\JoinTable(name: 'messages_files')]
|
|
|
+ #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id', onDelete: 'cascade')]
|
|
|
+ #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
|
|
|
+ protected Collection $files;
|
|
|
+
|
|
|
+ #[ORM\OneToMany(mappedBy: 'message', targetEntity: ReportMessage::class, cascade: ['persist'], orphanRemoval: true)]
|
|
|
+ protected Collection $reportMessage;
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
@@ -133,6 +140,30 @@ abstract class AbstractMessage
|
|
|
return $this->dateSent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return Collection<int, File>
|
|
|
+ */
|
|
|
+ public function getFiles(): Collection
|
|
|
+ {
|
|
|
+ return $this->files;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addFile(File $file): self
|
|
|
+ {
|
|
|
+ if (!$this->files->contains($file)) {
|
|
|
+ $this->files[] = $file;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeFile(File $file): self
|
|
|
+ {
|
|
|
+ $this->files->removeElement($file);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
function getReportMessage(): Collection
|
|
|
{
|
|
|
return $this->reportMessage;
|