src/Entity/Documents.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Traits\CommonTrt;
  4. use Doctrine\ORM\Mapping as ORM;
  5. // use JMS\Serializer\Annotation\Exclude;
  6. use App\Repository\DocumentsRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. /**
  14.  * @ORM\Entity(repositoryClass=DocumentsRepository::class)
  15.  * @Vich\Uploadable()
  16.  */
  17. class Documents
  18. {
  19.     use CommonTrt;
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @Assert\File(
  32.      *     maxSize = "10240M",
  33.      *     mimeTypes = {"application/pdf", "application/x-pdf", "image/jpeg", "image/png"},
  34.      *     mimeTypesMessage = "Veillez charger un fichier valide"
  35.      * )
  36.      * @Vich\UploadableField(mapping="uploads", fileNameProperty="fileName", mimeType="fileType", size="imageSize")
  37.      * @var File|null
  38.      */
  39.     private $documentFile;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      */
  43.     private $fileName;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $fileType;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $description;
  52.     /**
  53.      * @ORM\Column(type="integer", nullable=true)
  54.      *
  55.      * @var int|null
  56.      */
  57.     private $imageSize;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $url;
  62.     /**
  63.      * @ORM\Column(type="string", length=255)
  64.      */
  65.     private $slug;
  66.     /**
  67.      * @ORM\ManyToMany(targetEntity=Tag::class, inversedBy="documents")
  68.      */
  69.     private $tag;
  70.     /**
  71.      * @ORM\Column(type="integer", nullable=true)
  72.      */
  73.     private $fileSize;
  74.     /**
  75.      * @ORM\Column(type="json", nullable=true)
  76.      */
  77.     private $allImages = [];
  78.     /**
  79.      * @ORM\Column(type="integer", nullable=true)
  80.      */
  81.     private $orderNumber;
  82.     /**
  83.      * @ORM\Column(type="integer", nullable=true)
  84.      */
  85.     private $docsType;
  86.     /**
  87.      * @ORM\Column(type="boolean", nullable=true)
  88.      */
  89.     private $isActive;
  90.     public function __construct()
  91.     {
  92.         $this->tag = new ArrayCollection();
  93.     }
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getName(): ?string
  99.     {
  100.         return $this->name;
  101.     }
  102.     public function setName(string $name): self
  103.     {
  104.         $this->name = $name;
  105.         return $this;
  106.     }
  107.     /**
  108.      * Get the value of document_file
  109.      *
  110.      * @return  File|null
  111.      */
  112.     public function getDocumentFile(): ?File
  113.     {
  114.         return $this->documentFile;
  115.     }
  116.     /**
  117.      * Set the value of document_file
  118.      *
  119.      * @param File|null $document_file
  120.      *
  121.      * @return  self
  122.      */
  123.     public function setDocumentFile($documentFile)
  124.     {
  125.         $this->documentFile = $documentFile;
  126.         if ($documentFile instanceof UploadedFile) {
  127.             $this->updatedAt = new \DateTime();
  128.         }
  129.         return $this;
  130.     }
  131.     public function getFileName(): ?string
  132.     {
  133.         return $this->fileName;
  134.     }
  135.     public function setFileName(?string $fileName): self
  136.     {
  137.         $this->fileName = $fileName;
  138.         return $this;
  139.     }
  140.     public function getFileType(): ?string
  141.     {
  142.         return $this->fileType;
  143.     }
  144.     public function setFileType(?string $fileType): self
  145.     {
  146.         $this->fileType = $fileType;
  147.         return $this;
  148.     }
  149.     public function getDescription(): ?string
  150.     {
  151.         return $this->description;
  152.     }
  153.     public function setDescription(?string $description): self
  154.     {
  155.         $this->description = $description;
  156.         return $this;
  157.     }
  158.     public function getSlug(): ?string
  159.     {
  160.         return $this->slug;
  161.     }
  162.     public function setSlug(string $slug): self
  163.     {
  164.         $this->slug = $slug;
  165.         return $this;
  166.     }
  167.     public function setImageSize(?int $imageSize): void
  168.     {
  169.         $this->imageSize = $imageSize;
  170.     }
  171.     public function getImageSize(): ?int
  172.     {
  173.         return $this->imageSize;
  174.     }
  175.     public function getUrl(): ?string
  176.     {
  177.         return $this->url;
  178.     }
  179.     public function setUrl(?string $url): self
  180.     {
  181.         $this->url = $url;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection|Tag[]
  186.      */
  187.     public function getTag(): Collection
  188.     {
  189.         return $this->tag;
  190.     }
  191.     public function addTag(Tag $tag): self
  192.     {
  193.         if (!$this->tag->contains($tag)) {
  194.             $this->tag[] = $tag;
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeTag(Tag $tag): self
  199.     {
  200.         $this->tag->removeElement($tag);
  201.         return $this;
  202.     }
  203.     public function getFileSize(): ?int
  204.     {
  205.         return $this->fileSize;
  206.     }
  207.     public function setFileSize(?int $fileSize): self
  208.     {
  209.         $this->fileSize = $fileSize;
  210.         return $this;
  211.     }
  212.     public function getAllImages(): ?array
  213.     {
  214.         return $this->allImages;
  215.     }
  216.     public function setAllImages(?array $allImages): self
  217.     {
  218.         $this->allImages = $allImages;
  219.         return $this;
  220.     }
  221.     public function getOrderNumber(): ?int
  222.     {
  223.         return $this->orderNumber;
  224.     }
  225.     public function setOrderNumber(?int $orderNumber): self
  226.     {
  227.         $this->orderNumber = $orderNumber;
  228.         return $this;
  229.     }
  230.     public function getDocsType(): ?int
  231.     {
  232.         return $this->docsType;
  233.     }
  234.     public function setDocsType(int $docsType): self
  235.     {
  236.         $this->docsType = $docsType;
  237.         return $this;
  238.     }
  239.     public function isIsActive(): ?bool
  240.     {
  241.         return $this->isActive;
  242.     }
  243.     public function setIsActive(?bool $isActive): self
  244.     {
  245.         $this->isActive = $isActive;
  246.         return $this;
  247.     }
  248. }