<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Controller\Agent\Property\CreatePropertyCertificate;
use App\Repository\CertificateOfOwnershipFileRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @Vich\Uploadable
* @ApiResource(
* iri= "https://schema.org/ownership/propertyFiles",
* normalizationContext= {"groups" = {"certificate_of_ownership_file:read"},"swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"certificate_of_ownership_file:write"}, "swagger_definition_name"="Write"},
* itemOperations= {
* "get"={
* "security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')"
* },
* "delete" = {
* "security" = "is_granted('CERTIFICATE_DELETE', object)"
* }
* },
* collectionOperations= {
* "get"={"security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')" },
* "post" = {
* "controller" = CreatePropertyCertificate::class,
* "deserialize" = false,
* "security"="is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER') ",
* "validation_groups" = {"Default", "create_property_certificate"},
* "openapi_context" = {
* "requestBody" = {
* "content" = {
* "multipart/form-data" = {
* "schema" = {
* "type" = "object",
* "properties" = {
* "file" = {
* "type" = "string",
* "format" = "binary",
* },
* "property"={
* "type"="integer"
* }
* },
* },
* },
* },
* },
* },
* },
* }
* )}
* @ORM\Entity(repositoryClass=CertificateOfOwnershipFileRepository::class)
*/
class CertificateOfOwnershipFile
{
/**
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
* @ORM\Id
* @Groups({"property_certificat:read","property:read","mandate:read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Property", inversedBy="imgs")
* @ORM\JoinColumn(nullable=false)
* @Groups({"certificate_of_ownership_file:read", "certificate_of_ownership_file:write"})
*/
private ?Property $property;
/**
* @Vich\UploadableField(mapping="ownership_file", fileNameProperty="filePath")
* @Assert\File(
* maxSizeMessage = "File exceeds allowed size",
* mimeTypes = {"application/octet-stream", "application/pdf", "application/x-pdf", "image/png","image/jpeg","image/webp"},
* mimeTypesMessage = "Please upload a valid format"
* )
*/
public ?File $file = null;
/**
* @Groups({"property:read","mandate:read"})
*/
public ?string $contentUrl = null;
/**
* @ORM\Column(nullable=true)
* @Groups({"property:read","mandate:read"})
*/
public ?string $filePath = null;
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getFilePath(): ?string
{
return $this->filePath;
}
/**
* @param string|null $filePath
*
* @return $this
*/
public function setFilePath(?string $filePath): self
{
$this->filePath = $filePath;
return $this;
}
/**
* @return Property|null
*/
public function getProperty(): ?Property
{
return $this->property;
}
/**
* @param Property|null $property
* @return $this
*/
public function setProperty(?Property $property): self
{
$this->property = $property;
return $this;
}
}