<?php
namespace App\Entity;
use App\Traits\CommonTrt;
use Doctrine\ORM\Mapping as ORM;
// use JMS\Serializer\Annotation\Exclude;
use App\Repository\DocumentsRepository;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\HttpFoundation\File\File;
use Doctrine\Common\Collections\ArrayCollection;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Entity(repositoryClass=DocumentsRepository::class)
* @Vich\Uploadable()
*/
class Documents
{
use CommonTrt;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @Assert\File(
* maxSize = "10240M",
* mimeTypes = {"application/pdf", "application/x-pdf", "image/jpeg", "image/png"},
* mimeTypesMessage = "Veillez charger un fichier valide"
* )
* @Vich\UploadableField(mapping="uploads", fileNameProperty="fileName", mimeType="fileType", size="imageSize")
* @var File|null
*/
private $documentFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fileName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fileType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $imageSize;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\ManyToMany(targetEntity=Tag::class, inversedBy="documents")
*/
private $tag;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $fileSize;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $allImages = [];
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $orderNumber;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $docsType;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isActive;
public function __construct()
{
$this->tag = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* Get the value of document_file
*
* @return File|null
*/
public function getDocumentFile(): ?File
{
return $this->documentFile;
}
/**
* Set the value of document_file
*
* @param File|null $document_file
*
* @return self
*/
public function setDocumentFile($documentFile)
{
$this->documentFile = $documentFile;
if ($documentFile instanceof UploadedFile) {
$this->updatedAt = new \DateTime();
}
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getFileType(): ?string
{
return $this->fileType;
}
public function setFileType(?string $fileType): self
{
$this->fileType = $fileType;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getImageSize(): ?int
{
return $this->imageSize;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
/**
* @return Collection|Tag[]
*/
public function getTag(): Collection
{
return $this->tag;
}
public function addTag(Tag $tag): self
{
if (!$this->tag->contains($tag)) {
$this->tag[] = $tag;
}
return $this;
}
public function removeTag(Tag $tag): self
{
$this->tag->removeElement($tag);
return $this;
}
public function getFileSize(): ?int
{
return $this->fileSize;
}
public function setFileSize(?int $fileSize): self
{
$this->fileSize = $fileSize;
return $this;
}
public function getAllImages(): ?array
{
return $this->allImages;
}
public function setAllImages(?array $allImages): self
{
$this->allImages = $allImages;
return $this;
}
public function getOrderNumber(): ?int
{
return $this->orderNumber;
}
public function setOrderNumber(?int $orderNumber): self
{
$this->orderNumber = $orderNumber;
return $this;
}
public function getDocsType(): ?int
{
return $this->docsType;
}
public function setDocsType(int $docsType): self
{
$this->docsType = $docsType;
return $this;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
}