src/Entity/Bailleur.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BailleurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection; // Ajout nécessaire
  5. use Doctrine\Common\Collections\Collection; // Ajout nécessaire
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: BailleurRepository::class)]
  8. #[ORM\Table(name: 'Bailleur')]
  9. class Bailleur
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue]
  13. #[ORM\Column(type: 'integer')]
  14. private ?int $id = null;
  15. #[ORM\Column(length: 20)]
  16. private ?string $libele = null;
  17. #[ORM\Column(name: 'drapoCloture', type: 'boolean', options: ['default'=>false])]
  18. private bool $drapoCloture = false; // Initialisé à false par défaut
  19. #[ORM\OneToMany(mappedBy: 'bailleur', targetEntity: Projet::class)]
  20. private Collection $projets;
  21. public function __construct() {
  22. $this->projets = new ArrayCollection();
  23. }
  24. // --- Getters et Setters ---
  25. public function getId(): ?int { return $this->id; }
  26. public function getLibele(): ?string { return $this->libele; }
  27. public function setLibele(string $libele): self { $this->libele = $libele; return $this; }
  28. public function getDrapoCloture(): ?bool { return $this->drapoCloture; }
  29. public function setDrapoCloture(bool $drapoCloture): self { $this->drapoCloture = $drapoCloture; return $this; }
  30. /**
  31. * @return Collection<int, Projet>
  32. */
  33. public function getProjets(): Collection
  34. {
  35. return $this->projets;
  36. }
  37. public function addProjet(Projet $projet): static
  38. {
  39. if (!$this->projets->contains($projet)) {
  40. $this->projets->add($projet);
  41. $projet->setBailleur($this);
  42. }
  43. return $this;
  44. }
  45. public function removeProjet(Projet $projet): static
  46. {
  47. if ($this->projets->removeElement($projet)) {
  48. // Définir le côté propriétaire à null
  49. if ($projet->getBailleur() === $this) {
  50. $projet->setBailleur(null);
  51. }
  52. }
  53. return $this;
  54. }
  55. }