<?php
namespace App\Entity;
use App\Repository\ProjetRepository;
use Doctrine\Common\Collections\ArrayCollection; // Ajout nécessaire
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProjetRepository::class)]
class Projet
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Bailleur::class, inversedBy: 'projets')]
#[ORM\JoinColumn(nullable: false)]
private ?Bailleur $bailleur = null;
#[ORM\OneToMany(mappedBy: 'projet', targetEntity: LigneBudget::class)]
private Collection $budgets;
#[ORM\Column(length: 20)]
private ?string $libele = null;
public function __construct()
{
$this->budgets = new ArrayCollection();
}
/**
* @return Collection<int, LigneBudget>
*/
public function getBudgets(): Collection
{
return $this->budgets;
}
public function addBudget(LigneBudget $budget): static
{
if (!$this->budgets->contains($budget)) {
$this->budgets->add($budget);
$budget->setProjet($this);
}
return $this;
}
public function removeBudget(LigneBudget $budget): static
{
if ($this->budgets->removeElement($budget)) {
// Définir le côté propriétaire à null si nécessaire
if ($budget->getProjet() === $this) {
$budget->setProjet(null);
}
}
return $this;
}
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;
}
// --- Ajout des méthodes manquantes pour la relation ---
public function getBailleur(): ?Bailleur
{
return $this->bailleur;
}
public function setBailleur(?Bailleur $bailleur): self
{
$this->bailleur = $bailleur;
return $this;
}
}