<?php
namespace App\Entity;
use App\Repository\BrokerRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
#[ORM\Entity(repositoryClass: BrokerRepository::class)]
class Broker
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $brokerName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $brokerSurname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $brokerEmail = null;
#[ORM\OneToOne(mappedBy: 'broker', cascade: ['persist', 'remove'])]
private ?User $users = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $brokerPhone = null;
#[ORM\OneToMany(mappedBy: 'listingAgent', targetEntity: PropertyList::class, cascade: ['persist', 'remove'])]
private Collection $propertiesListed;
#[ORM\OneToMany(mappedBy: 'managingAgent', targetEntity: PropertyList::class, cascade: ['persist', 'remove'])]
private Collection $propertiesManaged;
#[ORM\OneToMany(mappedBy: 'sellingAgent', targetEntity: PropertyList::class, cascade: ['persist', 'remove'])]
private Collection $propertiesSold;
#[ORM\OneToMany(mappedBy: 'uploadedBy', targetEntity: Documents::class, cascade: ['persist', 'remove'])]
private Collection $document;
#[ORM\OneToMany(mappedBy: 'uploadedBy', targetEntity: DocsTenants::class, cascade: ['persist', 'remove'])]
private Collection $tenantDocument;
#[ORM\OneToMany(mappedBy: 'broker', targetEntity: Landlords::class)]
private Collection $landlords;
#[ORM\OneToMany(mappedBy: 'broker', targetEntity: PotentialClients::class)]
private Collection $potentialClient;
#[ORM\OneToMany(mappedBy: 'broker', targetEntity: Tenants::class)]
private Collection $tenant;
#[ORM\ManyToOne(targetEntity:"App\Entity\Broker", inversedBy:"subordinateBrokers")]
#[ORM\JoinColumn(name:"manager_id", referencedColumnName:"id")]
private ?Broker $manager =null;
#[ORM\OneToMany(targetEntity:"App\Entity\Broker", mappedBy:"manager")]
private $subordinateBrokers;
#[ORM\OneToMany(mappedBy: 'broker', targetEntity: Minutes::class, cascade: ['persist','remove'])]
private Collection $minutes;
public function __construct()
{
$this->propertiesManaged = new ArrayCollection();
$this->propertiesListed = new ArrayCollection();
$this->propertiesSold = new ArrayCollection();
$this->document = new ArrayCollection();
$this->tenantDocument = new ArrayCollection();
$this->landlords = new ArrayCollection();
$this->potentialClient = new ArrayCollection();
$this->tenant = new ArrayCollection();
$this->minutes = new ArrayCollection();
}
public function __toString(): string
{
return $this->getBrokerName().' '.$this->getBrokerSurname().'';
}
public function getId(): ?int
{
return $this->id;
}
public function getBrokerName(): ?string
{
return $this->brokerName;
}
public function setBrokerName(?string $brokerName): self
{
$this->brokerName = $brokerName;
return $this;
}
public function getBrokerSurname(): ?string
{
return $this->brokerSurname;
}
public function setBrokerSurname(?string $brokerSurname): self
{
$this->brokerSurname = $brokerSurname;
return $this;
}
public function getBrokerEmail(): ?string
{
return $this->brokerEmail;
}
public function setBrokerEmail(?string $brokerEmail): self
{
$this->brokerEmail = $brokerEmail;
return $this;
}
public function getUsers(): ?User
{
return $this->users;
}
public function setUsers(?User $users): self
{
// unset the owning side of the relation if necessary
if ($users === null && $this->users !== null) {
$this->users->setBroker(null);
}
// set the owning side of the relation if necessary
if ($users !== null && $users->getBroker() !== $this) {
$users->setBroker($this);
}
$this->users = $users;
return $this;
}
public function getBrokerPhone(): ?string
{
return $this->brokerPhone;
}
public function setBrokerPhone(?string $brokerPhone): self
{
$this->brokerPhone = $brokerPhone;
return $this;
}
////////////////// CAPTADOR / VENDEDOR / GESTOR ////////////////////////////
/**
* @return Collection<int, PropertyList>
*/
public function getPropertiesManaged(): Collection
{
return $this->propertiesManaged;
}
public function addPropertiesManaged(PropertyList $propertiesManaged): self
{
if (!$this->propertiesManaged->contains($propertiesManaged)) {
$this->propertiesManaged->add($propertiesManaged);
$propertiesManaged->setManagingAgent($this);
}
return $this;
}
public function removePropertiesManaged(PropertyList $propertiesManaged): self
{
if ($this->propertiesManaged->removeElement($propertiesManaged)) {
// set the owning side to null (unless already changed)
if ($propertiesManaged->getManagingAgent() === $this) {
$propertiesManaged->setManagingAgent(null);
}
}
return $this;
}
/**
* @return Collection<int, PropertyList>
*/
public function getPropertiesListed(): Collection
{
return $this->propertiesListed;
}
public function addPropertiesListed(PropertyList $propertiesListed): self
{
if (!$this->propertiesListed->contains($propertiesListed)) {
$this->propertiesListed->add($propertiesListed);
$propertiesListed->setListingAgent($this);
}
return $this;
}
public function removePropertiesListed(PropertyList $propertiesListed): self
{
if ($this->propertiesListed->removeElement($propertiesListed)) {
// set the owning side to null (unless already changed)
if ($propertiesListed->getListingAgent() === $this) {
$propertiesListed->setListingAgent(null);
}
}
return $this;
}
/**
* @return Collection<int, PropertyList>
*/
public function getPropertiesSold(): Collection
{
return $this->propertiesSold;
}
public function addPropertiesSold(PropertyList $propertiesSold): self
{
if (!$this->propertiesSold->contains($propertiesSold)) {
$this->propertiesSold->add($propertiesSold);
$propertiesSold->setSellingAgent($this);
}
return $this;
}
public function removePropertiesSold(PropertyList $propertiesSold): self
{
if ($this->propertiesSold->removeElement($propertiesSold)) {
// set the owning side to null (unless already changed)
if ($propertiesSold->getSellingAgent() === $this) {
$propertiesSold->setSellingAgent(null);
}
}
return $this;
}
//////////////////////////////////////////////////////////////////////////
/**
* @return Collection<int, Documents>
*/
public function getDocument(): Collection
{
return $this->document;
}
public function addDocument(Documents $document): self
{
if (!$this->document->contains($document)) {
$this->document->add($document);
$document->setUploadedBy($this);
}
return $this;
}
public function removeDocument(Documents $document): self
{
if ($this->document->removeElement($document)) {
// set the owning side to null (unless already changed)
if ($document->getUploadedBy() === $this) {
$document->setUploadedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, DocsTenants>
*/
public function getTenantDocument(): Collection
{
return $this->tenantDocument;
}
public function addTenantDocument(DocsTenants $tenantDocument): self
{
if (!$this->tenantDocument->contains($tenantDocument)) {
$this->tenantDocument->add($tenantDocument);
$tenantDocument->setUploadedBy($this);
}
return $this;
}
public function removeTenantDocument(DocsTenants $tenantDocument): self
{
if ($this->tenantDocument->removeElement($tenantDocument)) {
// set the owning side to null (unless already changed)
if ($tenantDocument->getUploadedBy() === $this) {
$tenantDocument->setUploadedBy(null);
}
}
return $this;
}
/**
* @return Collection<int, Landlords>
*/
public function getLandlords(): Collection
{
return $this->landlords;
}
public function addLandlord(Landlords $landlord): self
{
if (!$this->landlords->contains($landlord)) {
$this->landlords->add($landlord);
$landlord->setBroker($this);
}
return $this;
}
public function removeLandlord(Landlords $landlord): self
{
if ($this->landlords->removeElement($landlord)) {
// set the owning side to null (unless already changed)
if ($landlord->getBroker() === $this) {
$landlord->setBroker(null);
}
}
return $this;
}
/**
* @return Collection<int, PotentialClients>
*/
public function getPotentialClient(): Collection
{
return $this->potentialClient;
}
public function addPotentialClient(PotentialClients $potentialClient): self
{
if (!$this->potentialClient->contains($potentialClient)) {
$this->potentialClient->add($potentialClient);
$potentialClient->setBroker($this);
}
return $this;
}
public function removePotentialClient(PotentialClients $potentialClient): self
{
if ($this->potentialClient->removeElement($potentialClient)) {
// set the owning side to null (unless already changed)
if ($potentialClient->getBroker() === $this) {
$potentialClient->setBroker(null);
}
}
return $this;
}
/**
* @return Collection<int, Tenants>
*/
public function getTenant(): Collection
{
return $this->tenant;
}
public function addTenant(Tenants $tenant): self
{
if (!$this->tenant->contains($tenant)) {
$this->tenant->add($tenant);
$tenant->setBroker($this);
}
return $this;
}
public function removeTenant(Tenants $tenant): self
{
if ($this->tenant->removeElement($tenant)) {
// set the owning side to null (unless already changed)
if ($tenant->getBroker() === $this) {
$tenant->setBroker(null);
}
}
return $this;
}
public function getManager(): ?Broker
{
return $this->manager;
}
public function setManager(?Broker $manager): void
{
$this->manager = $manager;
//return $this;
}
public function getSubordinateBrokers()
{
return $this->subordinateBrokers;
}
/**
* @return Collection<int, Minutes>
*/
public function getMinutes(): Collection
{
return $this->minutes;
}
public function addMinute(Minutes $minute): self
{
if (!$this->minutes->contains($minute)) {
$this->minutes->add($minute);
$minute->setBroker($this);
}
return $this;
}
public function removeMinute(Minutes $minute): self
{
if ($this->minutes->removeElement($minute)) {
// set the owning side to null (unless already changed)
if ($minute->getBroker() === $this) {
$minute->setBroker(null);
}
}
return $this;
}
}