src/Entity/Documents.php line 21

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