Files
ludikevent_crm/src/Entity/EtatLieuxFile.php

131 lines
2.7 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\EtatLieuxFileRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Attribute\Uploadable;
use Vich\UploaderBundle\Mapping\Attribute\UploadableField;
#[ORM\Entity(repositoryClass: EtatLieuxFileRepository::class)]
#[Uploadable]
class EtatLieuxFile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'files')]
#[ORM\JoinColumn(nullable: false)]
private ?EtatLieux $etatLieux = null;
#[UploadableField(mapping: 'etat_lieux_media', fileNameProperty: 'fileName', size: 'fileSize', mimeType: 'mimeType')]
private ?File $file = null;
#[ORM\Column(nullable: true)]
private ?string $fileName = null;
#[ORM\Column(nullable: true)]
private ?int $fileSize = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $mimeType = null;
#[ORM\Column(length: 50)]
private ?string $type = null; // 'photo' or 'video'
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getEtatLieux(): ?EtatLieux
{
return $this->etatLieux;
}
public function setEtatLieux(?EtatLieux $etatLieux): static
{
$this->etatLieux = $etatLieux;
return $this;
}
public function getFile(): ?File
{
return $this->file;
}
public function setFile(?File $file): void
{
$this->file = $file;
if (null !== $file) {
$this->createdAt = new \DateTimeImmutable();
}
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): void
{
$this->fileName = $fileName;
}
public function getFileSize(): ?int
{
return $this->fileSize;
}
public function setFileSize(?int $fileSize): void
{
$this->fileSize = $fileSize;
}
public function getMimeType(): ?string
{
return $this->mimeType;
}
public function setMimeType(?string $mimeType): void
{
$this->mimeType = $mimeType;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
}