<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\DocumentRepository;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=DocumentRepository::class)
* @Vich\Uploadable
* @ApiResource(
* collectionOperations={"get","post"},
* itemOperations={"get","put","patch","delete"},
* normalizationContext={"groups"={"document"}},
* denormalizationContext={"groups"={"document"}},
* attributes={"pagination_enabled"=false}
* )
* @ApiFilter(
* BooleanFilter::class, properties={"isAvailable"}
* )
*/
class Document
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("document")
*/
private $id;
/**
* @ORM\Column(type="text")
* @Groups("document")
* @var string
*/
private $file;
/**
* @Vich\UploadableField(mapping="document_file", fileNameProperty="documentFile")
* @var File
*/
private $documentFile;
/**
* @ORM\Column(type="datetime", nullable = true)
* @var DateTime
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255)
* @Groups("user")
* @Groups("document")
*/
private $customerId;
/**
* @ORM\Column(type="integer")
* @Groups("document")
*/
private $type;
/**
* @ORM\Column(type="date")
* @Groups("document")
*/
private $validityDate;
/**
* @ORM\Column(type="integer")
* @Groups("document")
*/
private $documentNumber;
/**
* @ORM\Column(type="boolean")
*/
private $isAvailable;
/**
* @ORM\Column(type="date")
* @Groups("document")
*/
private $documentDate;
public function getId(): ?int
{
return $this->id;
}
public function setDocumentFile(File $file = null)
{
$this->documentFile = $file;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($file) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getUpdateAt()
{
return $this->updatedAt;
}
public function setUpdateAt(DateTime $dateTime)
{
$this->updatedAt = $dateTime;
}
public function getDocumentFIle()
{
return $this->documentFile;
}
public function setFile($file)
{
$this->file = $file;
}
public function getFile()
{
return $this->file;
}
public function getCustomerId(): ?string
{
return $this->customerId;
}
public function setCustomerId(string $customerId): self
{
$this->customerId = $customerId;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getValidityDate(): ?\DateTimeInterface
{
return $this->validityDate;
}
public function setValidityDate(\DateTimeInterface $validityDate): self
{
$this->validityDate = $validityDate;
return $this;
}
public function getDocumentNumber(): ?int
{
return $this->documentNumber;
}
public function setDocumentNumber(int $documentNumber): self
{
$this->documentNumber = $documentNumber;
return $this;
}
public function getIsAvailable(): ?bool
{
return $this->isAvailable;
}
public function setIsAvailable(bool $isAvailable): self
{
$this->isAvailable = $isAvailable;
return $this;
}
public function getDocumentDate(): ?\DateTimeInterface
{
return $this->documentDate;
}
public function setDocumentDate(\DateTimeInterface $documentDate): self
{
$this->documentDate = $documentDate;
return $this;
}
}