<?php
declare(strict_types=1);
namespace App\Domain\PropertyMatching\Adapters\Gateway\Doctrine;
use App\Entity\Agent;
use App\Entity\Property;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Uid\Ulid;
/**
* @ORM\Entity(repositoryClass=DoctrineMatchingRepository::class)
* @ORM\Table(name="property_matching")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
*/
class PropertyMatchingEntity
{
use SoftDeleteableEntity;
/**
* @var string|null
*
* @ORM\Id()
* @ORM\Column(type="ulid", unique=true)
*
* @Groups({
* "property:read","property:write","property:put",
* "mandate:read",
* "transaction-item:read"
* })
*/
private ?string $uuid;
/**
* @var string|null
*
* @ORM\Column(name="matching_type", type="string", nullable=false)
*/
private ?string $matchingType;
/**
* @var Property|null
*
* @ORM\ManyToOne(targetEntity=Property::class, inversedBy="matchingEntity")
*/
private ?Property $property = null;
/**
* @var Agent|null
*
* @ORM\ManyToOne(targetEntity=Agent::class)
*/
private ?Agent $agent = null;
/**
* @var \DateTimeInterface|null
*
* @ORM\Column(name="created_at", type="datetime_immutable", nullable=false)
*/
private ?\DateTimeInterface $createdAt;
/**
* @var PropertyMatchingSpecEntity
*
* @ORM\OneToOne (targetEntity=PropertyMatchingSpecEntity::class, inversedBy="matching", cascade={"persist"})
* @ORM\JoinColumn(name="specs_uuid", referencedColumnName="uuid")
*/
private PropertyMatchingSpecEntity $specs;
/**
* @var Collection<Property>
*/
private Collection $properties;
public function __construct()
{
$this->properties = new ArrayCollection();
$this->uuid = (new Ulid())->toBase32();
}
/**
* @return string|null
*/
public function getUuid(): ?string
{
return $this->uuid;
}
/**
* @param string|null $uuid
*
* @return $this
*/
public function setUuid(?string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* @return string|null
*/
public function getMatchingType(): ?string
{
return $this->matchingType;
}
/**
* @param string|null $matchingType
*
* @return $this
*/
public function setMatchingType(?string $matchingType): self
{
$this->matchingType = $matchingType;
return $this;
}
/**
* @return \DateTimeInterface|null
*/
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
/**
* @param \DateTimeInterface|null $createdAt
*
* @return $this
*/
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return PropertyMatchingSpecEntity
*/
public function getSpecs(): PropertyMatchingSpecEntity
{
return $this->specs;
}
/**
* @param PropertyMatchingSpecEntity $specs
*
* @return $this
*/
public function setSpecs(PropertyMatchingSpecEntity $specs): self
{
$this->specs = $specs;
return $this;
}
/**
* @return Collection
*/
public function getProperties(): Collection
{
return $this->properties;
}
/**
* @param Collection $properties
*
* @return $this
*/
public function setProperties(Collection $properties): self
{
$this->properties = $properties;
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;
}
/**
* @return Agent|null
*/
public function getAgent(): ?Agent
{
return $this->agent;
}
/**
* @param Agent|null $agent
*
* @return $this
*/
public function setAgent(?Agent $agent): self
{
$this->agent = $agent;
return $this;
}
}