<?php
namespace App\Entity;
use App\Repository\HabitationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: HabitationRepository::class)]
class Habitation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $lieu = null;
#[ORM\OneToMany(mappedBy: 'habitation', targetEntity: Membre::class)]
private Collection $membres;
public function __construct()
{
$this->membres = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLieu(): ?string
{
return $this->lieu;
}
public function setLieu(string $lieu): self
{
$this->lieu = $lieu;
return $this;
}
public function __toString(): string
{
return $this->getLieu();
}
/**
* @return Collection<int, Membre>
*/
public function getMembres(): Collection
{
return $this->membres;
}
public function addMembre(Membre $membre): self
{
if (!$this->membres->contains($membre)) {
$this->membres->add($membre);
$membre->setHabitation($this);
}
return $this;
}
public function removeMembre(Membre $membre): self
{
if ($this->membres->removeElement($membre)) {
// set the owning side to null (unless already changed)
if ($membre->getHabitation() === $this) {
$membre->setHabitation(null);
}
}
return $this;
}
}