src/Entity/Projet.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjetRepository;
  4. use Doctrine\Common\Collections\ArrayCollection; // Ajout nécessaire
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: ProjetRepository::class)]
  8. class Projet
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column]
  13. private ?int $id = null;
  14. #[ORM\ManyToOne(targetEntity: Bailleur::class, inversedBy: 'projets')]
  15. #[ORM\JoinColumn(nullable: false)]
  16. private ?Bailleur $bailleur = null;
  17. #[ORM\OneToMany(mappedBy: 'projet', targetEntity: LigneBudget::class)]
  18. private Collection $budgets;
  19. #[ORM\Column(length: 20)]
  20. private ?string $libele = null;
  21. public function __construct()
  22. {
  23. $this->budgets = new ArrayCollection();
  24. }
  25. /**
  26. * @return Collection<int, LigneBudget>
  27. */
  28. public function getBudgets(): Collection
  29. {
  30. return $this->budgets;
  31. }
  32. public function addBudget(LigneBudget $budget): static
  33. {
  34. if (!$this->budgets->contains($budget)) {
  35. $this->budgets->add($budget);
  36. $budget->setProjet($this);
  37. }
  38. return $this;
  39. }
  40. public function removeBudget(LigneBudget $budget): static
  41. {
  42. if ($this->budgets->removeElement($budget)) {
  43. // Définir le côté propriétaire à null si nécessaire
  44. if ($budget->getProjet() === $this) {
  45. $budget->setProjet(null);
  46. }
  47. }
  48. return $this;
  49. }
  50. public function getId(): ?int
  51. {
  52. return $this->id;
  53. }
  54. public function getLibele(): ?string
  55. {
  56. return $this->libele;
  57. }
  58. public function setLibele(string $libele): self
  59. {
  60. $this->libele = $libele;
  61. return $this;
  62. }
  63. // --- Ajout des méthodes manquantes pour la relation ---
  64. public function getBailleur(): ?Bailleur
  65. {
  66. return $this->bailleur;
  67. }
  68. public function setBailleur(?Bailleur $bailleur): self
  69. {
  70. $this->bailleur = $bailleur;
  71. return $this;
  72. }
  73. }