<?php

namespace App\Entity\Properties;

use Doctrine\ORM\Mapping as ORM;
use App\Entity\Acteurs\Demarcheur;
use App\Entity\Acteurs\Proprietaires;
use App\Entity\Parametres\Locations\Locations;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 */
class Bien
{
    use \App\Entity\Common\IdTrait;
    use \App\Entity\Common\DatesTrait;

    /**
     * @ORM\Column(type="string", length=150)
     */
    private string $name;

    /**
     * @ORM\Column(type="string", length=500, nullable=true)
     */
    private ?string $adresse = null;

    /**
     * @ORM\ManyToOne(targetEntity=Proprietaires::class)
     */
    private ?Proprietaires $proprietaire = null;

    /**
     * @ORM\ManyToOne(targetEntity=Demarcheur::class)
     */
    private ?Demarcheur $demarcheur = null;

    /**
     * @ORM\ManyToOne(targetEntity=Locations::class)
     */
    private ?Locations $zone = null;


    /**
     * @ORM\Column(type="decimal", precision=5, scale=2, nullable=true)
     */
    private ?float $commission = null; // Pourcentage de commission

    /**
     * @ORM\OneToMany(targetEntity=Properties::class, mappedBy="bien")
     */
    private Collection $properties;

    public function __construct()
    {
        $this->properties = new ArrayCollection();
    }

    // Getters / Setters...
    public function getName(): string
    {
        return $this->name;
    }
    public function setName(string $name): self
    {
        $this->name = $name;
        return $this;
    }

    public function getAdresse(): ?string
    {
        return $this->adresse;
    }
    public function setAdresse(?string $adresse): self
    {
        $this->adresse = $adresse;
        return $this;
    }

    public function getProprietaire(): ?Proprietaires
    {
        return $this->proprietaire;
    }
    public function setProprietaire(?Proprietaires $proprietaire): self
    {
        $this->proprietaire = $proprietaire;
        return $this;
    }

    public function getDemarcheur(): ?Demarcheur
    {
        return $this->demarcheur;
    }
    public function setDemarcheur(?Demarcheur $demarcheur): self
    {
        $this->demarcheur = $demarcheur;
        return $this;
    }

    public function getZone(): ?Locations
    {
        return $this->zone;
    }
    public function setZone(?Locations $zone): self
    {
        $this->zone = $zone;
        return $this;
    }

    public function getCommission(): ?float
    {
        return $this->commission;
    }
    public function setCommission(?float $commission): self
    {
        $this->commission = $commission;
        return $this;
    }

    public function getProperties(): Collection
    {
        return $this->properties;
    }
    public function addProperty(Properties $property): self
    {
        if (!$this->properties->contains($property)) {
            $this->properties[] = $property;
            $property->setBien($this);
        }
        return $this;
    }

    public function removeProperty(Properties $property): self
    {
        if ($this->properties->removeElement($property)) {
            if ($property->getBien() === $this) {
                $property->setBien(null);
            }
        }
        return $this;
    }
}
