<?php
namespace App\Entity;
use App\Repository\DocumentsRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\Constructor;
use App\Entity\PropertyList;
use ProxyManager\ProxyGenerator\Util\Properties;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: DocumentsRepository::class)]
#[Vich\Uploadable]
class Documents
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $docName = null;
/*
#[Assert\File(
maxSize:'1024k',
)]
#[ORM\Column(length: 255, nullable: true)]
*/
#[Vich\UploadableField(mapping: 'property_docs', fileNameProperty: 'docName')]
private ?File $docType = null;
/*
#[ORM\ManyToOne(inversedBy: 'documents', targetEntity: PropertyList::class, cascade: ['persist', 'remove'])]
private ?PropertyList $properties = null;
*/
#[ORM\Column(nullable: true)]
private ?int $docSize = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\ManyToOne(inversedBy: 'documents', cascade: ['persist'])]
private ?PropertyList $properties = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $docCategory = null;
#[ORM\ManyToOne(inversedBy: 'document', cascade: ['persist'])]
private ?Broker $uploadedBy = null;
#[ORM\ManyToOne(inversedBy: 'document', cascade: ['persist'])]
private ?User $uploadedByUser = null;
#[ORM\ManyToMany(targetEntity: Landlords::class, inversedBy: 'documents')]
private Collection $landlord;
#[ORM\Column(length: 255, nullable: true)]
private ?string $energy = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $occupancy = null;
#[Vich\UploadableField(mapping: 'property_docs', fileNameProperty: 'occupancy')]
private ?File $occupancyFile = null;
#[Vich\UploadableField(mapping: 'property_docs', fileNameProperty: 'energy')]
private ?File $energyFile = null;
/*
public function __toString(): string
{
return $this->getDocName().' ('.$this->getDocCategory().')';
}
*/
public function __toString(): string{
return $this->getDocName() ?? "Sin nombre";
}
public function __construct()
{
//$this->properties = new ArrayCollection();
$this->landlord = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDocName(): ?string
{
return $this->docName;
}
public function setDocName(?string $docName): self
{
$this->docName = $docName;
return $this;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $docType
*/
public function setDocType(?File $docType = null): void
{
$this->docType = $docType;
if (null !== $docType) {
$this->updatedAt = new \DateTimeImmutable();
}
//return $this;
}
public function getDocType(): ?File
{
return $this->docType;
}
public function getDocSize(): ?int
{
return $this->docSize;
}
public function setDocSize(?int $docSize): self
{
$this->docSize = $docSize;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/*
public function getProperties(): ?PropertyList
{
return $this->properties;
}
public function setProperties(?PropertyList $properties): self
{
$this->properties = $properties;
return $this;
}
public function addProperty(PropertyList $property): self
{
if (!$this->properties->contains($property)) {
$this->properties[] = $property;
$property->addDocument($this);
}
return $this;
}
public function removeProperty(PropertyList $property): self
{
if ($this->properties->removeElement($property)) {
$property->removeDocument($this);
}
return $this;
}
*/
public function getProperties(): ?PropertyList
{
return $this->properties;
}
public function setProperties(?PropertyList $properties): self
{
$this->properties = $properties;
return $this;
}
public function getDocCategory(): ?string
{
return $this->docCategory;
}
public function setDocCategory(?string $docCategory): self
{
$this->docCategory = $docCategory;
return $this;
}
public function getUploadedBy(): ?Broker
{
return $this->uploadedBy;
}
public function setUploadedBy(?Broker $uploadedBy): self
{
$this->uploadedBy = $uploadedBy;
return $this;
}
public function getUploadedByUser(): ?User
{
return $this->uploadedByUser;
}
public function setUploadedByUser(?User $uploadedByUser): self
{
$this->uploadedByUser = $uploadedByUser;
return $this;
}
/**
* @return Collection<int, Landlords>
*/
public function getLandlord(): Collection
{
return $this->landlord;
}
public function addLandlord(Landlords $landlord): self
{
if (!$this->landlord->contains($landlord)) {
$this->landlord->add($landlord);
}
return $this;
}
public function removeLandlord(Landlords $landlord): self
{
$this->landlord->removeElement($landlord);
return $this;
}
public function getEnergy(): ?string
{
return $this->energy;
}
public function setEnergy(?string $energy): self
{
$this->energy = $energy;
return $this;
}
public function getOccupancy(): ?string
{
return $this->occupancy;
}
public function setOccupancy(?string $occupancy): self
{
$this->occupancy = $occupancy;
return $this;
}
public function getOccupancyFile(): ?File
{
return $this->occupancyFile;
}
public function setOccupancyFile(?File $occupancyFile = null): void
{
$this->occupancyFile = $occupancyFile;
//return $this;
}
public function getEnergyFile(): ?File
{
return $this->energyFile;
}
public function setEnergyFile(?File $energyFile = null): void
{
$this->energyFile = $energyFile;
//return $this;
}
}