src/Entity/Document.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\DocumentRepository;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ORM\Entity(repositoryClass=DocumentRepository::class)
  15.  * @Vich\Uploadable
  16.  * @ApiResource(
  17.  *     collectionOperations={"get","post"},
  18.  *     itemOperations={"get","put","patch","delete"},
  19.  *     normalizationContext={"groups"={"document"}},
  20.  *     denormalizationContext={"groups"={"document"}},
  21.  *     attributes={"pagination_enabled"=false}
  22.  * )
  23.  *  @ApiFilter(
  24.  *      BooleanFilter::class, properties={"isAvailable"}
  25.  * )
  26.  */
  27. class Document
  28. {
  29.     /**
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue
  32.      * @ORM\Column(type="integer")
  33.      * @Groups("document")
  34.      */
  35.     private $id;
  36.     /**
  37.      * @ORM\Column(type="text")
  38.      * @Groups("document")
  39.      * @var string
  40.      */
  41.     private $file;
  42.     /**
  43.      * @Vich\UploadableField(mapping="document_file", fileNameProperty="documentFile")
  44.      * @var File
  45.      */
  46.     private $documentFile;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable = true)
  49.      * @var DateTime
  50.      */
  51.     private $updatedAt;
  52.     /**
  53.      * @ORM\Column(type="string", length=255)
  54.      * @Groups("user")
  55.      * @Groups("document")
  56.      */
  57.     private $customerId;
  58.     /**
  59.      * @ORM\Column(type="integer")
  60.      * @Groups("document")
  61.      */
  62.     private $type;
  63.     /**
  64.      * @ORM\Column(type="date")
  65.      * @Groups("document")
  66.      */
  67.     private $validityDate;
  68.     /**
  69.      * @ORM\Column(type="integer")
  70.      * @Groups("document")
  71.      */
  72.     private $documentNumber;
  73.     /**
  74.      * @ORM\Column(type="boolean")
  75.      */
  76.     private $isAvailable;
  77.     /**
  78.      * @ORM\Column(type="date")
  79.      * @Groups("document")
  80.      */
  81.     private $documentDate;
  82.     public function getId(): ?int
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function setDocumentFile(File $file null)
  87.     {
  88.         $this->documentFile $file;
  89.         // VERY IMPORTANT:
  90.         // It is required that at least one field changes if you are using Doctrine,
  91.         // otherwise the event listeners won't be called and the file is lost
  92.         if ($file) {
  93.             // if 'updatedAt' is not defined in your entity, use another property
  94.             $this->updatedAt = new \DateTime('now');
  95.         }
  96.     }
  97.     public function getUpdateAt()
  98.     {
  99.         return $this->updatedAt;
  100.     }
  101.     public function setUpdateAt(DateTime $dateTime)
  102.     {
  103.         $this->updatedAt $dateTime;
  104.     }
  105.     public function getDocumentFIle()
  106.     {
  107.         return $this->documentFile;
  108.     }
  109.     public function setFile($file)
  110.     {
  111.         $this->file $file;
  112.     }
  113.     public function getFile()
  114.     {
  115.         return $this->file;
  116.     }
  117.     public function getCustomerId(): ?string
  118.     {
  119.         return $this->customerId;
  120.     }
  121.     public function setCustomerId(string $customerId): self
  122.     {
  123.         $this->customerId $customerId;
  124.         return $this;
  125.     }
  126.     public function getType(): ?int
  127.     {
  128.         return $this->type;
  129.     }
  130.     public function setType(int $type): self
  131.     {
  132.         $this->type $type;
  133.         return $this;
  134.     }
  135.     public function getValidityDate(): ?\DateTimeInterface
  136.     {
  137.         return $this->validityDate;
  138.     }
  139.     public function setValidityDate(\DateTimeInterface $validityDate): self
  140.     {
  141.         $this->validityDate $validityDate;
  142.         return $this;
  143.     }
  144.     public function getDocumentNumber(): ?int
  145.     {
  146.         return $this->documentNumber;
  147.     }
  148.     public function setDocumentNumber(int $documentNumber): self
  149.     {
  150.         $this->documentNumber $documentNumber;
  151.         return $this;
  152.     }
  153.     public function getIsAvailable(): ?bool
  154.     {
  155.         return $this->isAvailable;
  156.     }
  157.     public function setIsAvailable(bool $isAvailable): self
  158.     {
  159.         $this->isAvailable $isAvailable;
  160.         return $this;
  161.     }
  162.     public function getDocumentDate(): ?\DateTimeInterface
  163.     {
  164.         return $this->documentDate;
  165.     }
  166.     public function setDocumentDate(\DateTimeInterface $documentDate): self
  167.     {
  168.         $this->documentDate $documentDate;
  169.         return $this;
  170.     }
  171. }