<?php
namespace App\Entity;
use App\Repository\BailleurRepository;
use Doctrine\Common\Collections\ArrayCollection; // Ajout nécessaire
use Doctrine\Common\Collections\Collection; // Ajout nécessaire
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: BailleurRepository::class)]
#[ORM\Table(name: 'Bailleur')]
class Bailleur
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(length: 20)]
private ?string $libele = null;
#[ORM\Column(name: 'drapoCloture', type: 'boolean', options: ['default'=>false])]
private bool $drapoCloture = false; // Initialisé à false par défaut
#[ORM\OneToMany(mappedBy: 'bailleur', targetEntity: Projet::class)]
private Collection $projets;
public function __construct() {
$this->projets = new ArrayCollection();
}
// --- Getters et Setters ---
public function getId(): ?int { return $this->id; }
public function getLibele(): ?string { return $this->libele; }
public function setLibele(string $libele): self { $this->libele = $libele; return $this; }
public function getDrapoCloture(): ?bool { return $this->drapoCloture; }
public function setDrapoCloture(bool $drapoCloture): self { $this->drapoCloture = $drapoCloture; return $this; }
/**
* @return Collection<int, Projet>
*/
public function getProjets(): Collection
{
return $this->projets;
}
public function addProjet(Projet $projet): static
{
if (!$this->projets->contains($projet)) {
$this->projets->add($projet);
$projet->setBailleur($this);
}
return $this;
}
public function removeProjet(Projet $projet): static
{
if ($this->projets->removeElement($projet)) {
// Définir le côté propriétaire à null
if ($projet->getBailleur() === $this) {
$projet->setBailleur(null);
}
}
return $this;
}
}